mlang: fix memory leaks in error paths (found by Smatch).

Lionel Debroux lionel_debroux at yahoo.fr
Mon Sep 24 07:12:10 CDT 2007


---
 dlls/mlang/mlang.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c
index b5b8e0d..eb14ad0 100644
--- a/dlls/mlang/mlang.c
+++ b/dlls/mlang/mlang.c
@@ -1885,7 +1885,11 @@ static HRESULT EnumRfc1766_create(MLang_impl* mlang, LANGID LangId,
     data.total = 0;
     data.allocated = 32;
     data.info = HeapAlloc(GetProcessHeap(), 0, data.allocated * sizeof(RFC1766INFO));
-    if (!data.info) return S_FALSE;
+    if (!data.info)
+    {
+        HeapFree(rfc);
+        return S_FALSE;
+    }
 
     TlsSetValue(MLANG_tls_index, &data);
     EnumSystemLocalesW(enum_locales_proc, 0/*LOCALE_SUPPORTED*/);
@@ -1893,7 +1897,12 @@ static HRESULT EnumRfc1766_create(MLang_impl* mlang, LANGID LangId,
 
     TRACE("enumerated %d rfc1766 structures\n", data.total);
 
-    if (!data.total) return FALSE;
+    if (!data.total)
+    {
+        HeapFree(data.info);
+        HeapFree(rfc);
+        return FALSE;
+    }
 
     rfc->info = data.info;
     rfc->total = data.total;
-- 
1.5.3.1


--------------090108020002010008040405--



More information about the wine-patches mailing list