Yet another round of redundand NULL checks before HeapFree (found
by Smatch).
Michael Stefaniuc
mstefani at redhat.de
Wed Jun 7 18:10:33 CDT 2006
Hello,
hopefully this should be the last round of redundand NULL checks before
HeapFree removals. I know, famous last words. But this time i have
extended the redundant_null_check.pl Smatch script to find all non-null
variables from arbitrary complex if-expressions and check that any of
them dosn't get HeapFree'd on the truth path.
bye
michael
---
dlls/comdlg32/filedlg31.c | 2 +-
dlls/dbghelp/msc.c | 2 +-
dlls/ddraw/executebuffer.c | 2 +-
dlls/mpr/wnet.c | 2 +-
dlls/msacm32/driver.c | 2 +-
dlls/ntdll/path.c | 2 +-
dlls/user/exticon.c | 4 ++--
dlls/user/listbox.c | 2 +-
8 files changed, 9 insertions(+), 9 deletions(-)
1a58fa65d907d04db0525cf527dd8186e9accca5
diff --git a/dlls/comdlg32/filedlg31.c b/dlls/comdlg32/filedlg31.c
index a283068..79141fa 100644
--- a/dlls/comdlg32/filedlg31.c
+++ b/dlls/comdlg32/filedlg31.c
@@ -764,7 +764,7 @@ void FD31_FreeOfnW(LPOPENFILENAMEW ofnW)
HeapFree(GetProcessHeap(), 0, ofnW->lpstrFileTitle);
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrInitialDir);
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrTitle);
- if ((ofnW->lpTemplateName) && (HIWORD(ofnW->lpTemplateName)))
+ if (HIWORD(ofnW->lpTemplateName))
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpTemplateName);
}
diff --git a/dlls/dbghelp/msc.c b/dlls/dbghelp/msc.c
index 4f044fb..fb6b413 100644
--- a/dlls/dbghelp/msc.c
+++ b/dlls/dbghelp/msc.c
@@ -370,7 +370,7 @@ static void codeview_clear_type_table(vo
for (i = 0; i < CV_MAX_MODULES; i++)
{
- if (cv_zmodules[i].allowed && cv_zmodules[i].defined_types)
+ if (cv_zmodules[i].allowed)
HeapFree(GetProcessHeap(), 0, cv_zmodules[i].defined_types);
cv_zmodules[i].allowed = FALSE;
cv_zmodules[i].defined_types = NULL;
diff --git a/dlls/ddraw/executebuffer.c b/dlls/ddraw/executebuffer.c
index bcd0f45..274c2a0 100644
--- a/dlls/ddraw/executebuffer.c
+++ b/dlls/ddraw/executebuffer.c
@@ -536,7 +536,7 @@ Main_IDirect3DExecuteBufferImpl_1_Releas
TRACE("(%p/%p)->()decrementing from %lu.\n", This, iface, ref + 1);
if (!ref) {
- if ((This->desc.lpData != NULL) && This->need_free)
+ if (This->need_free)
HeapFree(GetProcessHeap(),0,This->desc.lpData);
HeapFree(GetProcessHeap(),0,This->vertex_data);
HeapFree(GetProcessHeap(),0,This->indices);
diff --git a/dlls/mpr/wnet.c b/dlls/mpr/wnet.c
index 60a2a29..804b457 100644
--- a/dlls/mpr/wnet.c
+++ b/dlls/mpr/wnet.c
@@ -653,7 +653,7 @@ DWORD WINAPI WNetOpenEnumA( DWORD dwScop
if (ret == WN_SUCCESS)
ret = WNetOpenEnumW(dwScope, dwType, dwUsage, lpNetWide,
lphEnum);
- if (allocated && lpNetWide)
+ if (allocated)
HeapFree(GetProcessHeap(), 0, lpNetWide);
}
else
diff --git a/dlls/msacm32/driver.c b/dlls/msacm32/driver.c
index e537bc4..bec3526 100644
--- a/dlls/msacm32/driver.c
+++ b/dlls/msacm32/driver.c
@@ -587,7 +587,7 @@ MMRESULT WINAPI acmDriverOpen(PHACMDRIVE
return MMSYSERR_NOERROR;
gotError:
WARN("failed: ret = %08x\n", ret);
- if (pad && !pad->hDrvr)
+ if (!pad->hDrvr)
HeapFree(MSACM_hHeap, 0, pad);
return ret;
}
diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c
index cfe7fdb..e9286a0 100644
--- a/dlls/ntdll/path.c
+++ b/dlls/ntdll/path.c
@@ -802,7 +802,7 @@ static ULONG get_full_path_helper(LPCWST
if (reqsize) memcpy(buffer, ins_str, reqsize);
reqsize += deplen;
- if (ins_str && ins_str != tmp && ins_str != cd->Buffer)
+ if (ins_str != tmp && ins_str != cd->Buffer)
RtlFreeHeap(GetProcessHeap(), 0, ins_str);
collapse_path( buffer, mark );
diff --git a/dlls/user/exticon.c b/dlls/user/exticon.c
index ddc1ccd..6d64cc1 100644
--- a/dlls/user/exticon.c
+++ b/dlls/user/exticon.c
@@ -455,7 +455,7 @@ static UINT ICO_ExtractIconExW(
if (nIcons == 0)
{
ret = iconDirCount;
- if (lpiID && pCIDir) /* *.ico file, deallocate heap pointer*/
+ if (lpiID) /* *.ico file, deallocate heap pointer*/
HeapFree(GetProcessHeap(), 0, pCIDir);
}
else if (nIconIndex < iconDirCount)
@@ -472,7 +472,7 @@ static UINT ICO_ExtractIconExW(
pIconId[i] = LookupIconIdFromDirectoryEx(pCIDir, TRUE, cx1, cy1, flags);
if (cx2 && cy2) pIconId[++i] = LookupIconIdFromDirectoryEx(pCIDir, TRUE, cx2, cy2, flags);
}
- if (lpiID && pCIDir) /* *.ico file, deallocate heap pointer*/
+ if (lpiID) /* *.ico file, deallocate heap pointer*/
HeapFree(GetProcessHeap(), 0, pCIDir);
for (icon = 0; icon < nIcons; icon++)
diff --git a/dlls/user/listbox.c b/dlls/user/listbox.c
index 0b21a39..08c1eb7 100644
--- a/dlls/user/listbox.c
+++ b/dlls/user/listbox.c
@@ -1652,7 +1652,7 @@ static void LISTBOX_DeleteItem( LB_DESCR
dis.itemData = descr->items[index].data;
SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis );
}
- if (HAS_STRINGS(descr) && descr->items[index].str)
+ if (HAS_STRINGS(descr))
HeapFree( GetProcessHeap(), 0, descr->items[index].str );
}
--
1.3.3
--
Michael Stefaniuc Tel.: +49-711-96437-199
Sr. Network Engineer Fax.: +49-711-96437-111
Red Hat GmbH Email: mstefani at redhat.com
Hauptstaetterstr. 58 http://www.redhat.de/
D-70178 Stuttgart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20060608/1387f6a2/attachment.pgp
More information about the wine-patches
mailing list