summaryrefslogtreecommitdiff
path: root/libavformat/nutdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-05-10 22:30:43 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-05-10 22:31:39 +0200
commit55231323b0fdc84a529418d673148cf1f3157229 (patch)
tree1771ba123fc921a3ff05868b00243ec876802666 /libavformat/nutdec.c
parent73b8155b31ec7ad1132ecf5c45ac82acadeb28e5 (diff)
parent254f3daba4271c1918d9a7ad155b1442ef93ed29 (diff)
Merge commit '254f3daba4271c1918d9a7ad155b1442ef93ed29'
* commit '254f3daba4271c1918d9a7ad155b1442ef93ed29': nut: Make sure to clean up on read_header failure Conflicts: libavformat/nutdec.c See: 361702660d2c37a63b7d6381d39e1e1de8405260 Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/nutdec.c')
-rw-r--r--libavformat/nutdec.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index cd13e767d6..467dc5b867 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -745,7 +745,19 @@ fail:
return ret;
}
-static int nut_read_close(AVFormatContext *s);
+static int nut_read_close(AVFormatContext *s)
+{
+ NUTContext *nut = s->priv_data;
+ int i;
+
+ av_freep(&nut->time_base);
+ av_freep(&nut->stream);
+ ff_nut_free_sp(nut);
+ for (i = 1; i < nut->header_count; i++)
+ av_freep(&nut->header[i]);
+
+ return 0;
+}
static int nut_read_header(AVFormatContext *s)
{
@@ -762,8 +774,7 @@ 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");
- ret = AVERROR_INVALIDDATA;
- goto end;
+ goto fail;
}
} while (decode_main_header(nut) < 0);
@@ -773,8 +784,7 @@ 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");
- ret = AVERROR_INVALIDDATA;
- goto end;
+ goto fail;
}
if (decode_stream_header(nut) >= 0)
initialized_stream_count++;
@@ -788,8 +798,7 @@ static int nut_read_header(AVFormatContext *s)
if (startcode == 0) {
av_log(s, AV_LOG_ERROR, "EOF before video frames\n");
- ret = AVERROR_INVALIDDATA;
- goto end;
+ goto fail;
} else if (startcode == SYNCPOINT_STARTCODE) {
nut->next_startcode = startcode;
break;
@@ -815,6 +824,10 @@ end:
if (ret < 0)
nut_read_close(s);
return FFMIN(ret, 0);
+fail:
+ nut_read_close(s);
+
+ return AVERROR_INVALIDDATA;
}
static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
@@ -1214,20 +1227,6 @@ static int read_seek(AVFormatContext *s, int stream_index,
return 0;
}
-static int nut_read_close(AVFormatContext *s)
-{
- NUTContext *nut = s->priv_data;
- int i;
-
- av_freep(&nut->time_base);
- av_freep(&nut->stream);
- ff_nut_free_sp(nut);
- for (i = 1; i < nut->header_count; i++)
- av_freep(&nut->header[i]);
-
- return 0;
-}
-
AVInputFormat ff_nut_demuxer = {
.name = "nut",
.long_name = NULL_IF_CONFIG_SMALL("NUT"),