msi: fix memory leaks (found by Smatch).

James Hawkins truiken at gmail.com
Sun Dec 9 12:35:29 CST 2007


On Dec 9, 2007 4:44 AM, Lionel_Debroux <lionel_debroux at yahoo.fr> wrote:
> "msi_build_insertsql_data" and "MSI_DatabaseImport" in
> dlls/msi/database.c get flagged by Michael Stefaniuc's unfree-wine.pl
> script.
>
> It looks there are more leaks than unfree-wine.pl reports, due to
> constructs of the form
> ptr = msi_realloc(ptr, size);
> Fixed those as well.
>
> 2007-12-09  Lionel Debroux <lionel_debroux at yahoo.fr>
>         * dlls/msi/database.c:
>         msi: fix memory leaks (found by Smatch).
>

-        columns = msi_realloc(columns, sql_size * sizeof(WCHAR));
-        if (!columns)
+        temp_columns = msi_realloc(columns, sql_size * sizeof(WCHAR));
+        if (!temp_columns)
+        {
+            HeapFree( GetProcessHeap(), 0, columns);
             return NULL;
+        }

         lstrcatW(columns, expanded);


This is wrong.  There's no guarantee that realloc returns the same
position in memory.

-- 
James Hawkins



More information about the wine-devel mailing list