SMATCH: fixes for some unfreed mem in dlls/ole32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

found by the unfree-wine.pl smatch script.

License: LGPL, X11
Changelog:
	Michael Stefaniuc <mstefani@redhat.com>
	- fixes for mem leaks on error path
	- one fix for use of previous released pointer
-- 
Michael Stefaniuc               Tel.: +49-711-96437-199
System Administration           Fax.: +49-711-96437-111
Red Hat GmbH                    Email: mstefani@redhat.com
Hauptstaetterstr. 58            http://www.redhat.de/
D-70178 Stuttgart
Index: dlls/ole32/compositemoniker.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/compositemoniker.c,v
retrieving revision 1.24
diff -u -r1.24 compositemoniker.c
--- dlls/ole32/compositemoniker.c	11 Sep 2003 03:06:25 -0000	1.24
+++ dlls/ole32/compositemoniker.c	27 Sep 2003 23:50:15 -0000
@@ -1632,14 +1632,14 @@
     int i;
 
 
+    if (currentPos > tabSize)
+        return E_INVALIDARG;
+
     newEnumMoniker = HeapAlloc(GetProcessHeap(), 0, sizeof(EnumMonikerImpl));
 
     if (newEnumMoniker == 0)
         return STG_E_INSUFFICIENTMEMORY;
 
-    if (currentPos > tabSize)
-        return E_INVALIDARG;
-
     /* Initialize the virtual function table. */
     newEnumMoniker->lpVtbl       = &VT_EnumMonikerImpl;
     newEnumMoniker->ref          = 0;
@@ -1649,8 +1649,10 @@
 
     newEnumMoniker->tabMoniker=HeapAlloc(GetProcessHeap(),0,tabSize*sizeof(IMoniker));
 
-    if (newEnumMoniker->tabMoniker==NULL)
+    if (newEnumMoniker->tabMoniker==NULL) {
+        HeapFree(GetProcessHeap(), 0, newEnumMoniker);
         return E_OUTOFMEMORY;
+    }
 
     if (leftToRigth)
         for (i=0;i<tabSize;i++){
Index: dlls/ole32/filemoniker.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/filemoniker.c,v
retrieving revision 1.25
diff -u -r1.25 filemoniker.c
--- dlls/ole32/filemoniker.c	11 Sep 2003 03:06:25 -0000	1.25
+++ dlls/ole32/filemoniker.c	27 Sep 2003 23:50:16 -0000
@@ -281,6 +281,7 @@
     /* read filePath string */
     filePathA=HeapAlloc(GetProcessHeap(),0,length);
     res=IStream_Read(pStm,filePathA,length,&bread);
+    HeapFree(GetProcessHeap(),0,filePathA);
     if (bread != length)
         return E_FAIL;
 
@@ -330,8 +331,6 @@
 
     This->filePathName=filePathW;
 
-    HeapFree(GetProcessHeap(),0,filePathA);
-
     return res;
 }
 
@@ -1030,6 +1029,7 @@
     IMoniker_IsSystemMoniker(pmkOther,&mkSys);
 
     if(mkSys==MKSYS_FILEMONIKER){
+        HRESULT ret;
 
         CreateBindCtx(0,&pbind);
 
@@ -1068,24 +1068,26 @@
             sameIdx--;
 
         if (machimeNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
-            return MK_E_NOPREFIX;
-
-        for(i=0;i<sameIdx;i++)
-            strcatW(commonPath,stringTable1[i]);
-
-        for(i=0;i<nb1;i++)
-            CoTaskMemFree(stringTable1[i]);
-
-        CoTaskMemFree(stringTable1);
-
-        for(i=0;i<nb2;i++)
-            CoTaskMemFree(stringTable2[i]);
-
-        CoTaskMemFree(stringTable2);
-
+            ret = MK_E_NOPREFIX;
+        else
+        {
+            for(i=0;i<sameIdx;i++)
+                strcatW(commonPath,stringTable1[i]);
+    
+            for(i=0;i<nb1;i++)
+                CoTaskMemFree(stringTable1[i]);
+    
+            CoTaskMemFree(stringTable1);
+    
+            for(i=0;i<nb2;i++)
+                CoTaskMemFree(stringTable2[i]);
+    
+            CoTaskMemFree(stringTable2);
+    
+            ret = CreateFileMoniker(commonPath,ppmkPrefix);
+        }
         HeapFree(GetProcessHeap(),0,commonPath);
-
-        return CreateFileMoniker(commonPath,ppmkPrefix);
+        return ret;
     }
     else
         return MonikerCommonPrefixWith(iface,pmkOther,ppmkPrefix);
Index: dlls/ole32/ole16.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/ole16.c,v
retrieving revision 1.7
diff -u -r1.7 ole16.c
--- dlls/ole32/ole16.c	9 Sep 2003 19:39:31 -0000	1.7
+++ dlls/ole32/ole16.c	27 Sep 2003 23:50:16 -0000
@@ -376,10 +376,8 @@
     if (ret == S_OK)
     {
       ret = _xmalloc16(buf2len+1, (SEGPTR*)lplpszProgID);
-      if (ret != S_OK)
-        return ret;
-      strcpy(MapSL((SEGPTR)*lplpszProgID),buf2);
-      ret = S_OK;
+      if (ret == S_OK)
+        strcpy(MapSL((SEGPTR)*lplpszProgID),buf2);
     }
     HeapFree(GetProcessHeap(), 0, buf2);
   }

Attachment: pgp00190.pgp
Description: PGP signature


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux