---
corrected cosmetic errors
libavformat/nutdec.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
index 838c181..7119f95 100644
--- a/libavformat/nutdec.c
+++ b/libavformat/nutdec.c
@@ -231,6 +231,8 @@ static int decode_main_header(NUTContext *nut)
GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / sizeof(AVRational));
nut->time_base = av_malloc(nut->time_base_count * sizeof(AVRational));
+ if (!nut->time_base)
+ return AVERROR(ENOMEM);
for (i = 0; i < nut->time_base_count; i++) {
GET_V(nut->time_base[i].num, tmp > 0 && tmp < (1ULL << 31));
GET_V(nut->time_base[i].den, tmp > 0 && tmp < (1ULL << 31));
@@ -312,8 +314,13 @@ static int decode_main_header(NUTContext *nut)
return AVERROR_INVALIDDATA;
}
hdr = av_malloc(nut->header_len[i]);
- if (!hdr)
+ if (!hdr) {
+ int j;
+ for (j = 1; j < i; j++)
+ av_freep(&nut->header_len[j]);
+ av_free(nut->time_base);
return AVERROR(ENOMEM);
+ }
avio_read(bc, hdr, nut->header_len[i]);
nut->header[i] = hdr;
}
@@ -331,6 +338,13 @@ static int decode_main_header(NUTContext *nut)
}
nut->stream = av_mallocz(sizeof(StreamContext) * stream_count);
+ if (!nut->stream) {
+ int j;
+ for (j = 1; j < nut->header_count; j++)
+ av_freep(&nut->header_len[j]);
+ av_free(nut->time_base);
+ return AVERROR(ENOMEM);
+ }
for (i = 0; i < stream_count; i++)
avformat_new_stream(s, NULL);
@@ -405,6 +419,8 @@ static int decode_stream_header(NUTContext *nut)
if (st->codec->extradata_size) {
st->codec->extradata = av_mallocz(st->codec->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!st->codec->extradata)
+ return AVERROR(ENOMEM);
avio_read(bc, st->codec->extradata, st->codec->extradata_size);
}
@@ -599,6 +615,10 @@ static int find_and_decode_index(NUTContext *nut)
GET_V(syncpoint_count, tmp < INT_MAX / 8 && tmp > 0);
syncpoints = av_malloc(sizeof(int64_t) * syncpoint_count);
has_keyframe = av_malloc(sizeof(int8_t) * (syncpoint_count + 1));
+ if (!syncpoints || !has_keyframe) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
for (i = 0; i < syncpoint_count; i++) {
syncpoints[i] = ffio_read_varlen(bc);
if (syncpoints[i] <= 0)
@@ -812,7 +832,7 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int
frame_code)
{
AVFormatContext *s = nut->avf;
AVIOContext *bc = s->pb;
- int size, stream_id, discard;
+ int size, stream_id, discard, ret;
int64_t pts, last_IP_pts;
StreamContext *stc;
uint8_t header_idx;
@@ -837,7 +857,9 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int
frame_code)
return 1;
}
- av_new_packet(pkt, size + nut->header_len[header_idx]);
+ ret = av_new_packet(pkt, size + nut->header_len[header_idx]);
+ if (ret < 0)
+ return ret;
memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
pkt->pos = avio_tell(bc); // FIXME
avio_read(bc, pkt->data + nut->header_len[header_idx], size);
--
1.9.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel