From 177577932e89772ef7ab281dd5771d5c66ad3a93 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sun, 21 Oct 2018 16:01:26 +0200 Subject: qwindowsxpstyle: Add std::nothrow to new There is no sense in testing the 'buf' pointer against null, as the memory was allocated using the throwing 'new' operator. However, since this function already can fail in other cases, the 'buf' pointer can be checked for nullptr after the nothrow new. Task-number: QTBUG-71156 Change-Id: Ibca5d672544d3980dd8890474e3e2fbf7443e05d Reviewed-by: Thiago Macieira --- src/plugins/styles/windowsvista/qwindowsxpstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index 4b583e13d3..43e8b37f71 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -511,8 +511,8 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData) if (numBytes == 0) return QRegion(); - char *buf = new char[numBytes]; - if (buf == 0) + char *buf = new (std::nothrow) char[numBytes]; + if (!buf) return QRegion(); RGNDATA *rd = reinterpret_cast(buf); -- cgit v1.2.3