diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp index 99e8ec8999..1cb14514ee 100644 --- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp +++ b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp @@ -449,7 +449,9 @@ QStringList QWindowsPrintDevice::availablePrintDeviceIds() QString QWindowsPrintDevice::defaultPrintDeviceId() { DWORD size = 0; - GetDefaultPrinter(NULL, &size); + if (GetDefaultPrinter(NULL, &size) == ERROR_FILE_NOT_FOUND) + return QString(); + QScopedArrayPointer name(new wchar_t[size]); GetDefaultPrinter(name.data(), &size); return QString::fromWCharArray(name.data());