plugins/ogg: Fix leaking comment on error path
authorLucas De Marchi <lucas.demarchi@intel.com>
Mon, 12 Aug 2013 14:53:05 +0000 (11:53 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Fri, 16 Aug 2013 18:05:02 +0000 (15:05 -0300)
We need to call vorbis_comment_clear() on error path.

src/plugins/ogg/ogg.c

index 320525c..df9df5f 100644 (file)
@@ -88,6 +88,8 @@ _get_vorbis_comment(FILE *file, vorbis_comment *vc)
 
     osync = lms_create_ogg_sync();
 
+    vorbis_comment_init(vc);
+
     while (1) {
         buffer = lms_get_ogg_sync_buffer(osync, CHUNKSIZE);
         bytes = fread(buffer, 1, CHUNKSIZE, file);
@@ -104,8 +106,6 @@ _get_vorbis_comment(FILE *file, vorbis_comment *vc)
     serial = ogg_page_serialno(&og);
     os = lms_create_ogg_stream(serial);
 
-    vorbis_comment_init(vc);
-
     if (ogg_stream_pagein(os, &og) < 0 ||
         ogg_stream_packetout(os, &header) != 1 ||
         vorbis_synthesis_headerin(&vi, vc, &header) != 0)
@@ -146,6 +146,8 @@ _get_vorbis_comment(FILE *file, vorbis_comment *vc)
 
 end:
     vorbis_info_clear(&vi);
+    if (ret)
+        vorbis_comment_clear(vc);
 
     if (os)
         lms_destroy_ogg_stream(os);