]> granicus.if.org Git - libass/commitdiff
Fix leaks when error occurs.
authorXidorn Quan <quanxunzhen@gmail.com>
Sun, 2 Dec 2012 07:42:31 +0000 (15:42 +0800)
committerGrigori Goronzy <greg@monster>
Fri, 14 Dec 2012 22:17:59 +0000 (23:17 +0100)
libass/ass.c

index bc05d691e721cb112ebbb63d9377ee4ee9a9aa2f..fdeb93ca881c1703719c464092b11820fb8621ae 100644 (file)
@@ -988,7 +988,9 @@ static char *sub_recode(ASS_Library *library, char *data, size_t size,
                     oleft += size;
                 } else {
                     ass_msg(library, MSGL_WARN, "Error recoding file");
-                    return NULL;
+                    free(outbuf);
+                    outbuf = NULL;
+                    goto out;
                 }
             } else if (clear)
                 break;
@@ -996,6 +998,7 @@ static char *sub_recode(ASS_Library *library, char *data, size_t size,
         outbuf[osize - oleft - 1] = 0;
     }
 
+out:
     if (icdsc != (iconv_t) (-1)) {
         (void) iconv_close(icdsc);
         icdsc = (iconv_t) (-1);