From 1ca7435754793af982a880cd354752222a180fe1 Mon Sep 17 00:00:00 2001 From: Andrew Talbot Date: Fri, 14 Sep 2007 00:16:11 +0100 Subject: [PATCH] comdlg32: Fix some memory leaks. --- dlls/comdlg32/printdlg.c | 14 ++++++++++++-- dlls/comdlg32/printdlg16.c | 9 +++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dlls/comdlg32/printdlg.c b/dlls/comdlg32/printdlg.c index f3736ce8e6c..8e334c38cca 100644 --- a/dlls/comdlg32/printdlg.c +++ b/dlls/comdlg32/printdlg.c @@ -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); diff --git a/dlls/comdlg32/printdlg16.c b/dlls/comdlg32/printdlg16.c index 6aa8c6cc64f..65921f6281b 100644 --- a/dlls/comdlg32/printdlg16.c +++ b/dlls/comdlg32/printdlg16.c @@ -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);