mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-16 03:53:01 -05:00
Avoid needless memory management error if EnumPrinters returns no
printers. [originally from svn r1588]
This commit is contained in:
parent
e4712f729d
commit
42cbf97a09
@ -26,11 +26,16 @@ printer_enum *printer_start_enum(int *nprinters_ptr)
|
|||||||
buffer, 512, &needed, &nprinters) == 0)
|
buffer, 512, &needed, &nprinters) == 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (needed) {
|
||||||
buffer = srealloc(buffer, needed);
|
buffer = srealloc(buffer, needed);
|
||||||
|
|
||||||
if (EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5,
|
if (EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5,
|
||||||
(LPBYTE)buffer, needed, &needed, &nprinters) == 0)
|
(LPBYTE)buffer, needed, &needed, &nprinters) == 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
} else {
|
||||||
|
nprinters = 0;
|
||||||
|
ret->info = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ret->info = (LPPRINTER_INFO_5)buffer;
|
ret->info = (LPPRINTER_INFO_5)buffer;
|
||||||
ret->nprinters = *nprinters_ptr = nprinters;
|
ret->nprinters = *nprinters_ptr = nprinters;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user