QTranslator: avoid unhandled exception

Add std::nothrow param to avoid exception and
to check pointer against nullptr.

Change-Id: I505abb1ca15b8c10a80b0cd3784a6b0c4c6bcc1c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Anton Kudryavtsev 2018-10-15 20:36:06 +03:00 committed by Anton Kudryavtsev
parent 50f3f8f6bb
commit c0b265662e

View File

@ -72,6 +72,7 @@
#endif
#include <stdlib.h>
#include <new>
#include "qobject_p.h"
@ -592,7 +593,7 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo
#endif // QT_USE_MMAP
if (!ok) {
d->unmapPointer = new char[d->unmapLength];
d->unmapPointer = new (std::nothrow) char[d->unmapLength];
if (d->unmapPointer) {
file.seek(0);
qint64 readResult = file.read(d->unmapPointer, d->unmapLength);