diff mbox series

[3/5] iconv_charmap: Close output file when done

Message ID 20210727174129.3612656-4-siddhesh@sourceware.org
State Committed
Commit 1e0e6d656db9dfa12ef7eb67976385d3deb0d4ff
Delegated to: Arjun Shankar
Headers show
Series Static analysis fixes | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Siddhesh Poyarekar July 27, 2021, 5:41 p.m. UTC
---
 iconv/iconv_charmap.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Arjun Shankar Aug. 3, 2021, 3:15 p.m. UTC | #1
Hi Siddhesh,

> ---
>  iconv/iconv_charmap.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/iconv/iconv_charmap.c b/iconv/iconv_charmap.c
> index e2d53fee3c..a8b6b56124 100644
> --- a/iconv/iconv_charmap.c
> +++ b/iconv/iconv_charmap.c
> @@ -234,6 +234,8 @@ charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
>      while (++remaining < argc);
>  
>    /* All done.  */
> +  if (output != stdout)
> +    fclose (output);
>    free_table (cvtbl);
>    return status;
>  }

Earlier on, output is either the result of an fopen, or assigned stdout.
So, this change looks right.

Reviewed-by: Arjun Shankar <arjun@redhat.com>

Cheers!
diff mbox series

Patch

diff --git a/iconv/iconv_charmap.c b/iconv/iconv_charmap.c
index e2d53fee3c..a8b6b56124 100644
--- a/iconv/iconv_charmap.c
+++ b/iconv/iconv_charmap.c
@@ -234,6 +234,8 @@  charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
     while (++remaining < argc);
 
   /* All done.  */
+  if (output != stdout)
+    fclose (output);
   free_table (cvtbl);
   return status;
 }