charmap_conversion: Free conversion table on exit

Message ID 20210511171648.360163-1-siddhesh@sourceware.org
State Superseded
Headers
Series charmap_conversion: Free conversion table on exit |

Checks

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

Commit Message

Siddhesh Poyarekar May 11, 2021, 5:16 p.m. UTC
  The conversion table is allocated using xcalloc but never freed.
---
 iconv/iconv_charmap.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Siddhesh Poyarekar May 17, 2021, 3:59 p.m. UTC | #1
Ping!  I'll push this one too in a couple of days if there are no 
objections since it is a pretty trivial fix.

Siddhesh

On 5/11/21 10:46 PM, Siddhesh Poyarekar via Libc-alpha wrote:
> The conversion table is allocated using xcalloc but never freed.
> ---
>   iconv/iconv_charmap.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/iconv/iconv_charmap.c b/iconv/iconv_charmap.c
> index f76b3ce2b1..e3d12b04e3 100644
> --- a/iconv/iconv_charmap.c
> +++ b/iconv/iconv_charmap.c
> @@ -228,6 +228,7 @@ charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
>       while (++remaining < argc);
>   
>     /* All done.  */
> +  free (cvtbl);
>     return status;
>   }
>   
>
  
Adhemerval Zanella May 17, 2021, 5:02 p.m. UTC | #2
On 11/05/2021 14:16, Siddhesh Poyarekar via Libc-alpha wrote:
> The conversion table is allocated using xcalloc but never freed.

LGTM, although I would wrap it on a free_table since it is allocated
on both use_from_charmap and use_both_charmaps with allocate_table.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  iconv/iconv_charmap.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/iconv/iconv_charmap.c b/iconv/iconv_charmap.c
> index f76b3ce2b1..e3d12b04e3 100644
> --- a/iconv/iconv_charmap.c
> +++ b/iconv/iconv_charmap.c
> @@ -228,6 +228,7 @@ charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
>      while (++remaining < argc);
>  
>    /* All done.  */
> +  free (cvtbl);
>    return status;
>  }
  
Siddhesh Poyarekar May 18, 2021, 3:55 a.m. UTC | #3
On 5/17/21 10:32 PM, Adhemerval Zanella via Libc-alpha wrote:
> 
> 
> On 11/05/2021 14:16, Siddhesh Poyarekar via Libc-alpha wrote:
>> The conversion table is allocated using xcalloc but never freed.
> 
> LGTM, although I would wrap it on a free_table since it is allocated
> on both use_from_charmap and use_both_charmaps with allocate_table.

OK, I've made this change.  I'll post the committed patch shortly.

Thanks,
Siddhesh
  

Patch

diff --git a/iconv/iconv_charmap.c b/iconv/iconv_charmap.c
index f76b3ce2b1..e3d12b04e3 100644
--- a/iconv/iconv_charmap.c
+++ b/iconv/iconv_charmap.c
@@ -228,6 +228,7 @@  charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
     while (++remaining < argc);
 
   /* All done.  */
+  free (cvtbl);
   return status;
 }