From 374659033e8eeea5b25246a9ef80bee3ebc2cde9 Mon Sep 17 00:00:00 2001 From: Hilko Bengen Date: Mon, 12 Jul 2010 14:50:31 +0100 Subject: [PATCH] Call iconv_close along error path out of function. --- lib/hivex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/hivex.c b/lib/hivex.c index c65f6de..2b22924 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -1275,12 +1275,16 @@ windows_utf16_to_utf8 (/* const */ char *input, size_t len) size_t r = iconv (ic, &inp, &inlen, &outp, &outlen); if (r == (size_t) -1) { if (errno == E2BIG) { + int err = errno; size_t prev = outalloc; /* Try again with a larger output buffer. */ free (out); outalloc *= 2; - if (outalloc < prev) + if (outalloc < prev) { + iconv_close (ic); + errno = err; return NULL; + } goto again; } else { -- 1.8.3.1