xmv: do not leak memory in the error paths in xmv_read_header()
authorAnton Khirnov <anton@khirnov.net>
Thu, 28 Mar 2013 09:34:47 +0000 (10:34 +0100)
committerReinhard Tartler <siretart@tauware.de>
Wed, 24 Apr 2013 19:01:14 +0000 (21:01 +0200)
CC: libav-stable@libav.org
(cherry picked from commit f8080bd13b5f7fc48204b17fa59a5ce9feb15f07)

Signed-off-by: Reinhard Tartler <siretart@tauware.de>
libavformat/xmv.c

index bc4b239..ee4aec3 100644 (file)
@@ -178,8 +178,10 @@ static int xmv_read_header(AVFormatContext *s,
         return AVERROR(ENOMEM);
 
     xmv->audio = av_malloc(xmv->audio_track_count * sizeof(XMVAudioPacket));
-    if (!xmv->audio)
-        return AVERROR(ENOMEM);
+    if (!xmv->audio) {
+        ret = AVERROR(ENOMEM);
+        goto fail;
+    }
 
     for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
         XMVAudioTrack  *track  = &xmv->audio_tracks[audio_track];
@@ -213,8 +215,10 @@ static int xmv_read_header(AVFormatContext *s,
                                       "(0x%04X)\n", track->flags);
 
         ast = avformat_new_stream(s, NULL);
-        if (!ast)
-            return AVERROR(ENOMEM);
+        if (!ast) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
 
         ast->codec->codec_type            = AVMEDIA_TYPE_AUDIO;
         ast->codec->codec_id              = track->codec_id;