]> diplodocus.org Git - nmh/commitdiff
Plugged memory leak in convert_content_charset().
authorDavid Levine <levinedl@acm.org>
Sat, 15 Oct 2016 18:21:13 +0000 (14:21 -0400)
committerDavid Levine <levinedl@acm.org>
Sat, 15 Oct 2016 18:21:13 +0000 (14:21 -0400)
uip/mhshowsbr.c

index 37fc86f82f2560b87aa007d318ba4cce7146754a..093c97767042c7d1251026c4e792fc5d28359af2 100644 (file)
@@ -1266,20 +1266,22 @@ convert_content_charset (CT ct, char **file) {
     /* Using current locale, see if the content needs to be converted. */
 
     /* content_charset() cannot return NULL. */
     /* Using current locale, see if the content needs to be converted. */
 
     /* content_charset() cannot return NULL. */
-    char *charset = content_charset (ct);
+    char *src_charset = content_charset (ct);
 
 
-    if (! check_charset (charset, strlen (charset))) {
+    if (! check_charset (src_charset, strlen (src_charset))) {
         int unused = 0;
 
         int unused = 0;
 
-        char *charset = getcpy (get_charset ());
+        char *dest_charset = getcpy (get_charset ());
 
 
-        if (convert_charset (ct, charset, &unused) == 0) {
+        if (convert_charset (ct, dest_charset, &unused) == 0) {
             *file = ct->c_cefile.ce_file;
         } else {
             status = NOTOK;
         }
             *file = ct->c_cefile.ce_file;
         } else {
             status = NOTOK;
         }
+
+        free (dest_charset);
     }
     }
-    free (charset);
+    free (src_charset);
 #else  /* ! HAVE_ICONV */
     NMH_UNUSED (ct);
     NMH_UNUSED (file);
 #else  /* ! HAVE_ICONV */
     NMH_UNUSED (ct);
     NMH_UNUSED (file);