From 333451411bd475aadf85daf821942f34460d6ae2 Mon Sep 17 00:00:00 2001 From: Lionel_Debroux Date: Wed, 26 Sep 2007 14:25:26 +0200 Subject: [PATCH] mlang: Fix memory leaks in error paths (found by Smatch). --- dlls/mlang/mlang.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/mlang/mlang.c b/dlls/mlang/mlang.c index 7a77df5f8ca..b6bd57ecf39 100644 --- a/dlls/mlang/mlang.c +++ b/dlls/mlang/mlang.c @@ -1884,7 +1884,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(GetProcessHeap(), 0, rfc); + return S_FALSE; + } TlsSetValue(MLANG_tls_index, &data); EnumSystemLocalesW(enum_locales_proc, 0/*LOCALE_SUPPORTED*/); @@ -1892,7 +1896,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(GetProcessHeap(), 0, data.info); + HeapFree(GetProcessHeap(), 0, rfc); + return FALSE; + } rfc->info = data.info; rfc->total = data.total;