[COMMITTED,1/3] charmap_conversion: Free conversion table on exit

Message ID 20210518044012.910681-1-siddhesh@sourceware.org
State Committed
Commit c8c3c5e89a5f6a9d41d244e9803ccaf4250e7e62
Headers
Series [COMMITTED,1/3] charmap_conversion: Free conversion table on exit |

Checks

Context Check Description
dj/TryBot-apply_patch fail Patch failed to apply to master at the time it was sent

Commit Message

Siddhesh Poyarekar May 18, 2021, 4:40 a.m. UTC
  The conversion table is allocated using xcalloc but never freed.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
---
 iconv/iconv_charmap.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Patch

diff --git a/iconv/iconv_charmap.c b/iconv/iconv_charmap.c
index f76b3ce2b1..e2d53fee3c 100644
--- a/iconv/iconv_charmap.c
+++ b/iconv/iconv_charmap.c
@@ -53,6 +53,12 @@  allocate_table (void)
   return (struct convtable *) xcalloc (1, sizeof (struct convtable));
 }
 
+static inline void
+free_table (struct convtable *tbl)
+{
+  free (tbl);
+}
+
 
 static inline int
 is_term (struct convtable *tbl, unsigned int idx)
@@ -228,6 +234,7 @@  charmap_conversion (const char *from_code, struct charmap_t *from_charmap,
     while (++remaining < argc);
 
   /* All done.  */
+  free_table (cvtbl);
   return status;
 }