Commit 1ca74357 authored by Andrew Talbot's avatar Andrew Talbot Committed by Alexandre Julliard

comdlg32: Fix some memory leaks.

parent 4ccd78c2
......@@ -2059,7 +2059,10 @@ BOOL WINAPI PrintDlgA(LPPRINTDLGA lppd)
GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
dbuf = HeapAlloc(GetProcessHeap(),0,needed);
if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
ERR("GetPrinterDriverA failed, le %d, fix your config for printer %s!\n",GetLastError(),pbuf->pPrinterName);
ERR("GetPrinterDriverA failed, le %d, fix your config for printer %s!\n",
GetLastError(),pbuf->pPrinterName);
HeapFree(GetProcessHeap(), 0, dbuf);
HeapFree(GetProcessHeap(), 0, pbuf);
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
return FALSE;
}
......@@ -2206,7 +2209,10 @@ BOOL WINAPI PrintDlgW(LPPRINTDLGW lppd)
GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
dbuf = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*needed);
if (!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
ERR("GetPrinterDriverA failed, le %d, fix your config for printer %s!\n",GetLastError(),debugstr_w(pbuf->pPrinterName));
ERR("GetPrinterDriverA failed, le %d, fix your config for printer %s!\n",
GetLastError(),debugstr_w(pbuf->pPrinterName));
HeapFree(GetProcessHeap(), 0, dbuf);
HeapFree(GetProcessHeap(), 0, pbuf);
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
return FALSE;
}
......@@ -2615,6 +2621,8 @@ PRINTDLG_PS_ChangeActivePrinterA(LPSTR name, PageSetupDataA *pda){
lpDriverInfo = HeapAlloc(GetProcessHeap(), 0, needed);
if(!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)lpDriverInfo, needed, &needed)) {
ERR("GetPrinterDriverA failed for %s, fix your config!\n", lpPrinterInfo->pPrinterName);
HeapFree(GetProcessHeap(), 0, lpDriverInfo);
HeapFree(GetProcessHeap(), 0, lpPrinterInfo);
return FALSE;
}
ClosePrinter(hprn);
......@@ -2622,6 +2630,8 @@ PRINTDLG_PS_ChangeActivePrinterA(LPSTR name, PageSetupDataA *pda){
needed = DocumentPropertiesA(0, 0, name, NULL, NULL, 0);
if(needed == -1) {
ERR("DocumentProperties fails on %s\n", debugstr_a(name));
HeapFree(GetProcessHeap(), 0, lpDriverInfo);
HeapFree(GetProcessHeap(), 0, lpPrinterInfo);
return FALSE;
}
pDevMode = HeapAlloc(GetProcessHeap(), 0, needed);
......
......@@ -390,9 +390,10 @@ BOOL16 WINAPI PrintDlg16(
GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
dbuf = HeapAlloc(GetProcessHeap(),0,needed);
if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)dbuf, needed, &needed)) {
ERR("GetPrinterDriverA failed for %s, le %d, fix your config!\n",
pbuf->pPrinterName,GetLastError());
HeapFree(GetProcessHeap(), 0, dbuf);
ERR("GetPrinterDriverA failed for %s, le %d, fix your config!\n",
pbuf->pPrinterName,GetLastError());
HeapFree(GetProcessHeap(), 0, dbuf);
HeapFree(GetProcessHeap(), 0, pbuf);
COMDLG32_SetCommDlgExtendedError(PDERR_RETDEFFAILURE);
return FALSE;
}
......@@ -506,7 +507,7 @@ BOOL16 WINAPI PrintDlg16(
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
HeapFree(GetProcessHeap(), 0, PrintStructures->lpPrinterInfo);
HeapFree(GetProcessHeap(), 0, PrintStructures->lpDriverInfo);
HeapFree(GetProcessHeap(), 0, PrintStructures);
HeapFree(GetProcessHeap(), 0, ptr16);
}
if(bRet && (lppd->Flags & PD_RETURNDC || lppd->Flags & PD_RETURNIC))
bRet = PRINTDLG_CreateDC16(lppd);
......
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