charmap_conversion: Free conversion table on exit

Message ID 20210511171648.360163-1-siddhesh@sourceware.org
State New
Headers show
Series
  • charmap_conversion: Free conversion table on exit
Related show

Commit Message

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

-- 
2.31.1

Comments

Mark Brown via Libc-alpha May 17, 2021, 3:59 p.m. | #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;

>   }

>   

>
Mark Brown via Libc-alpha May 17, 2021, 5:02 p.m. | #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;

>  }
Mark Brown via Libc-alpha May 18, 2021, 3:55 a.m. | #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;
 }