From 0cdb44f01f0e7cc5405b1358149e7719db77bf03 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 25 Mar 2022 18:03:19 +0100 Subject: [PATCH] Windows: Fix potential crash when retrieving default printer GetDefaultPrinter() has been observed to return size == 0. Pick-to: 6.3 6.2 5.15 Fixes: QTBUG-53290 Change-Id: Id4c7a06d14d368c792e15e55cacf2366b6aedc7b Reviewed-by: Andy Shaw --- src/printsupport/platform/windows/qwindowsprintdevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/printsupport/platform/windows/qwindowsprintdevice.cpp b/src/printsupport/platform/windows/qwindowsprintdevice.cpp index a6aa9c6504a..faf491d9a90 100644 --- a/src/printsupport/platform/windows/qwindowsprintdevice.cpp +++ b/src/printsupport/platform/windows/qwindowsprintdevice.cpp @@ -499,7 +499,7 @@ QStringList QWindowsPrintDevice::availablePrintDeviceIds() QString QWindowsPrintDevice::defaultPrintDeviceId() { DWORD size = 0; - if (GetDefaultPrinter(nullptr, &size) == ERROR_FILE_NOT_FOUND) + if (GetDefaultPrinter(nullptr, &size) == ERROR_FILE_NOT_FOUND || size < 2) return QString(); QScopedArrayPointer name(new wchar_t[size]);