channels: Check return value of EnumPrinters

This commit is contained in:
Martin Fleisz 2023-03-23 15:01:58 +01:00 committed by akallabeth
parent 2fed8fb62e
commit ecb4712a10

View File

@ -1106,18 +1106,23 @@ UINT printer_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
{ {
WINPR_ASSERT(driver->EnumPrinters); WINPR_ASSERT(driver->EnumPrinters);
rdpPrinter** printers = driver->EnumPrinters(driver); rdpPrinter** printers = driver->EnumPrinters(driver);
rdpPrinter** current = printers; if (printers)
for (i = 0; current[i]; i++)
{ {
rdpPrinter* printer = current[i]; for (rdpPrinter** current = printers; *current; ++current)
if ((error = printer_register(pEntryPoints, printer)))
{ {
WLog_ERR(TAG, "printer_register failed with error %" PRIu32 "!", error); error = printer_register(pEntryPoints, *current);
break; if (error)
{
WLog_ERR(TAG, "printer_register failed with error %" PRIu32 "!", error);
break;
}
} }
} }
else
{
WLog_ERR(TAG, "Failed to enumerate printers!");
error = CHANNEL_RC_INITIALIZATION_ERROR;
}
WINPR_ASSERT(driver->ReleaseEnumPrinters); WINPR_ASSERT(driver->ReleaseEnumPrinters);
driver->ReleaseEnumPrinters(printers); driver->ReleaseEnumPrinters(printers);