Commit 5d47a691 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winspool: Don't leak the handle returned by AddPrinter.

parent 9674011d
...@@ -494,6 +494,7 @@ static BOOL CUPS_LoadPrinters(void) ...@@ -494,6 +494,7 @@ static BOOL CUPS_LoadPrinters(void)
HKEY hkeyPrinter, hkeyPrinters; HKEY hkeyPrinter, hkeyPrinters;
char loaderror[256]; char loaderror[256];
WCHAR nameW[MAX_PATH]; WCHAR nameW[MAX_PATH];
HANDLE added_printer;
cupshandle = wine_dlopen(SONAME_LIBCUPS, RTLD_NOW, loaderror, sizeof(loaderror)); cupshandle = wine_dlopen(SONAME_LIBCUPS, RTLD_NOW, loaderror, sizeof(loaderror));
if (!cupshandle) { if (!cupshandle) {
...@@ -548,10 +549,10 @@ static BOOL CUPS_LoadPrinters(void) ...@@ -548,10 +549,10 @@ static BOOL CUPS_LoadPrinters(void)
pi2.pShareName = emptyStringW; pi2.pShareName = emptyStringW;
pi2.pSepFile = emptyStringW; pi2.pSepFile = emptyStringW;
if (!AddPrinterW(NULL, 2, (LPBYTE)&pi2)) { added_printer = AddPrinterW( NULL, 2, (LPBYTE)&pi2 );
if (GetLastError() != ERROR_PRINTER_ALREADY_EXISTS) if (added_printer) ClosePrinter( added_printer );
ERR("printer '%s' not added by AddPrinter (error %d)\n", debugstr_w(nameW), GetLastError()); else if (GetLastError() != ERROR_PRINTER_ALREADY_EXISTS)
} ERR( "printer '%s' not added by AddPrinter (error %d)\n", debugstr_w(nameW), GetLastError() );
} }
HeapFree(GetProcessHeap(),0,port); HeapFree(GetProcessHeap(),0,port);
...@@ -571,8 +572,8 @@ static BOOL CUPS_LoadPrinters(void) ...@@ -571,8 +572,8 @@ static BOOL CUPS_LoadPrinters(void)
} }
#endif #endif
static BOOL static BOOL PRINTCAP_ParseEntry( const char *pent, BOOL isfirst )
PRINTCAP_ParseEntry(const char *pent, BOOL isfirst) { {
PRINTER_INFO_2A pinfo2a; PRINTER_INFO_2A pinfo2a;
const char *r; const char *r;
size_t name_len; size_t name_len;
...@@ -581,6 +582,7 @@ PRINTCAP_ParseEntry(const char *pent, BOOL isfirst) { ...@@ -581,6 +582,7 @@ PRINTCAP_ParseEntry(const char *pent, BOOL isfirst) {
char *port = NULL, *env_default; char *port = NULL, *env_default;
HKEY hkeyPrinter, hkeyPrinters; HKEY hkeyPrinter, hkeyPrinters;
WCHAR devnameW[MAX_PATH]; WCHAR devnameW[MAX_PATH];
HANDLE added_printer;
while (isspace(*pent)) pent++; while (isspace(*pent)) pent++;
r = strchr(pent,':'); r = strchr(pent,':');
...@@ -678,10 +680,10 @@ PRINTCAP_ParseEntry(const char *pent, BOOL isfirst) { ...@@ -678,10 +680,10 @@ PRINTCAP_ParseEntry(const char *pent, BOOL isfirst) {
pinfo2a.pShareName = share_name; pinfo2a.pShareName = share_name;
pinfo2a.pSepFile = sep_file; pinfo2a.pSepFile = sep_file;
if (!AddPrinterA(NULL,2,(LPBYTE)&pinfo2a)) { added_printer = AddPrinterA( NULL, 2, (LPBYTE)&pinfo2a );
if (GetLastError()!=ERROR_PRINTER_ALREADY_EXISTS) if (added_printer) ClosePrinter( added_printer );
ERR("%s not added by AddPrinterA (%d)\n",name,GetLastError()); else if (GetLastError() != ERROR_PRINTER_ALREADY_EXISTS)
} ERR( "printer '%s' not added by AddPrinter (error %d)\n", debugstr_a(name), GetLastError() );
} }
RegCloseKey(hkeyPrinters); RegCloseKey(hkeyPrinters);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment