Skip to content

Commit

Permalink
Windows: Fix potential crash when retrieving default printer
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
FriedemannKleint committed Mar 29, 2022
1 parent d85c652 commit 0cdb44f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/printsupport/platform/windows/qwindowsprintdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<wchar_t> name(new wchar_t[size]);
Expand Down

0 comments on commit 0cdb44f

Please sign in to comment.