[Qemu-devel] [PATCHv2] curses ui: add missing iconv_close calls

Samuel Thibault posted 1 patch 4 days ago
Test asan passed
Test docker-clang@ubuntu passed
Test docker-mingw@fedora passed
Test checkpatch passed
Failed in applying to current master (apply log)
ui/curses.c | 6 ++++++
1 file changed, 6 insertions(+)

[Qemu-devel] [PATCHv2] curses ui: add missing iconv_close calls

Posted by Samuel Thibault 4 days ago
The iconv_t are opened but never closed.

Spotted by Coverity: CID 1399708
Spotted by Coverity: CID 1399709
Spotted by Coverity: CID 1399713

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---

Change since previous version: close all iconv_t, not only
ucs_to_wchar_conv.

 ui/curses.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ui/curses.c b/ui/curses.c
index 3a7e8649f3..d29098db9f 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -519,6 +519,7 @@ static void font_setup(void)
 
     wchar_to_ucs_conv = iconv_open("UCS-2", "WCHAR_T");
     if (wchar_to_ucs_conv == (iconv_t) -1) {
+        iconv_close(ucs_to_wchar_conv);
         fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n",
                         strerror(errno));
         exit(1);
@@ -526,6 +527,8 @@ static void font_setup(void)
 
     font_conv = iconv_open("WCHAR_T", font_charset);
     if (font_conv == (iconv_t) -1) {
+        iconv_close(ucs_to_wchar_conv);
+        iconv_close(wchar_to_ucs_conv);
         fprintf(stderr, "Could not convert font glyphs from %s: '%s'\n",
                         font_charset, strerror(errno));
         exit(1);
@@ -646,6 +649,9 @@ static void font_setup(void)
             }
         }
     }
+    iconv_close(ucs_to_wchar_conv);
+    iconv_close(wchar_to_ucs_conv);
+    iconv_close(font_conv);
 }
 
 static void curses_setup(void)
-- 
2.20.1


Re: [Qemu-devel] [PATCHv2] curses ui: add missing iconv_close calls

Posted by Gerd Hoffmann 20 hours ago
On Thu, Mar 14, 2019 at 06:25:24PM +0100, Samuel Thibault wrote:
> The iconv_t are opened but never closed.
> 
> Spotted by Coverity: CID 1399708
> Spotted by Coverity: CID 1399709
> Spotted by Coverity: CID 1399713
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
> 
> Change since previous version: close all iconv_t, not only
> ucs_to_wchar_conv.

Added to UI patch queue.

thanks,
  Gerd


Re: [Qemu-devel] [PATCHv2] curses ui: add missing iconv_close calls

Posted by Peter Maydell 3 days ago
On Thu, 14 Mar 2019 at 17:26, Samuel Thibault
<samuel.thibault@ens-lyon.org> wrote:
>
> The iconv_t are opened but never closed.
>
> Spotted by Coverity: CID 1399708
> Spotted by Coverity: CID 1399709
> Spotted by Coverity: CID 1399713
>
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM