Lionel_Debroux wrote:
> EnumRfc1766_create leaks some heap memory in two error paths. Found in
> Michael Stefaniuc's list of Wine potential bugs detected by Smatch.
>
> 2007-09-24 Lionel Debroux <lionel_debroux(a)yahoo.fr>
> * dlls/mlang/mlang.c:
> mlang: fix memory leaks in error paths (found by Smatch).
>
>
>
> ------------------------------------------------------------------------
>
>>From 394f63633148d76fa322b726218e8a824e5a3930 Mon Sep 17 00:00:00 2001
> From: Lionel Debroux <lionel_debroux(a)yahoo.fr>
> Date: Mon, 24 Sep 2007 14:12:10 +0200
> Subject: mlang: fix memory leaks in error paths (found by Smatch).
>
> ---
> 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;
Err, screw that. The two first parameters "GetProcessHeap(), 0, " of the
three HeapFree calls are missing...
I did not forget to launch a make process to check my modifications were
correct, though. What happened was that everything was recompiled, and
by the time the compiler complained, I had already sent the mails by
mistake...
Sorry.
Lionel Debroux.