[FFmpeg-cvslog] nutdec: fix memleaks on error in nut_read_header
Andreas Cadhalpun
git at videolan.org
Mon Jun 1 13:28:43 CEST 2015
ffmpeg | branch: release/2.2 | Andreas Cadhalpun <andreas.cadhalpun at googlemail.com> | Tue Apr 28 20:58:21 2015 +0200| [b216e8b02bbc263d0eae9f61a59e582d5e4c91a3] | committer: Michael Niedermayer
nutdec: fix memleaks on error in nut_read_header
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 361702660d2c37a63b7d6381d39e1e1de8405260)
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b216e8b02bbc263d0eae9f61a59e582d5e4c91a3
---
libavformat/nutdec.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 68e0205..424eb8d 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -718,12 +718,14 @@ fail:
return ret;
}
+static int nut_read_close(AVFormatContext *s);
+
static int nut_read_header(AVFormatContext *s)
{
NUTContext *nut = s->priv_data;
AVIOContext *bc = s->pb;
int64_t pos;
- int initialized_stream_count;
+ int initialized_stream_count, ret = 0;
nut->avf = s;
@@ -733,7 +735,8 @@ static int nut_read_header(AVFormatContext *s)
pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1;
if (pos < 0 + 1) {
av_log(s, AV_LOG_ERROR, "No main startcode found.\n");
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto end;
}
} while (decode_main_header(nut) < 0);
@@ -743,7 +746,8 @@ static int nut_read_header(AVFormatContext *s)
pos = find_startcode(bc, STREAM_STARTCODE, pos) + 1;
if (pos < 0 + 1) {
av_log(s, AV_LOG_ERROR, "Not all stream headers found.\n");
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto end;
}
if (decode_stream_header(nut) >= 0)
initialized_stream_count++;
@@ -757,7 +761,8 @@ static int nut_read_header(AVFormatContext *s)
if (startcode == 0) {
av_log(s, AV_LOG_ERROR, "EOF before video frames\n");
- return AVERROR_INVALIDDATA;
+ ret = AVERROR_INVALIDDATA;
+ goto end;
} else if (startcode == SYNCPOINT_STARTCODE) {
nut->next_startcode = startcode;
break;
@@ -779,7 +784,10 @@ static int nut_read_header(AVFormatContext *s)
ff_metadata_conv_ctx(s, NULL, ff_nut_metadata_conv);
- return 0;
+end:
+ if (ret < 0)
+ nut_read_close(s);
+ return FFMIN(ret, 0);
}
static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
More information about the ffmpeg-cvslog
mailing list