Fix a memory leak in vorbis_commentheader_out().
authorTim Terriberry <tterribe@xiph.org>
Fri, 4 Nov 2011 23:55:47 +0000 (23:55 +0000)
committerTim Terriberry <tterribe@xiph.org>
Fri, 4 Nov 2011 23:55:47 +0000 (23:55 +0000)
Fixes #1840.
Thanks to Alexandru Munteanu for the patch.

svn path=/trunk/vorbis/; revision=18115

lib/info.c

index 7ca3ea8..76347ef 100644 (file)
@@ -550,7 +550,10 @@ int vorbis_commentheader_out(vorbis_comment *vc,
   oggpack_buffer opb;
 
   oggpack_writeinit(&opb);
-  if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;
+  if(_vorbis_pack_comment(&opb,vc)){
+    oggpack_writeclear(&opb);
+    return OV_EIMPL;
+  }
 
   op->packet = _ogg_malloc(oggpack_bytes(&opb));
   memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
@@ -561,6 +564,7 @@ int vorbis_commentheader_out(vorbis_comment *vc,
   op->granulepos=0;
   op->packetno=1;
 
+  oggpack_writeclear(&opb);
   return 0;
 }