diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2019-12-10 22:59:53 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2019-12-12 19:25:33 +0100 |
commit | c1e439d7e9abab3cebdc937636393b1656e095d9 (patch) | |
tree | be0ae941a23b62c42b152e2b9aa0a22f8c793d4e /libavformat/smacker.c | |
parent | cb88cdf7730e309df22ddbbc1ae4ebcd9ebc529e (diff) | |
download | ffmpeg-c1e439d7e9abab3cebdc937636393b1656e095d9.tar.gz |
avformat: Forward errors where possible
It is not uncommon to find code where the caller thinks to know better
what the return value should be than the callee. E.g. something like
"if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit
changes several instances of this to instead forward the actual error.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/smacker.c')
-rw-r--r-- | libavformat/smacker.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 239894dad0..6de0e7a0f1 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -233,13 +233,13 @@ static int smacker_read_header(AVFormatContext *s) /* load trees to extradata, they will be unpacked by decoder */ - if(ff_alloc_extradata(st->codecpar, smk->treesize + 16)){ + if ((ret = ff_alloc_extradata(st->codecpar, smk->treesize + 16)) < 0) { av_log(s, AV_LOG_ERROR, "Cannot allocate %"PRIu32" bytes of extradata\n", smk->treesize + 16); av_freep(&smk->frm_size); av_freep(&smk->frm_flags); - return AVERROR(ENOMEM); + return ret; } ret = avio_read(pb, st->codecpar->extradata + 16, st->codecpar->extradata_size - 16); if(ret != st->codecpar->extradata_size - 16){ @@ -353,8 +353,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) } if (frame_size < 0 || frame_size >= INT_MAX/2) return AVERROR_INVALIDDATA; - if (av_new_packet(pkt, frame_size + 769)) - return AVERROR(ENOMEM); + if ((ret = av_new_packet(pkt, frame_size + 769)) < 0) + return ret; if(smk->frm_size[smk->cur_frame] & 1) palchange |= 2; pkt->data[0] = palchange; @@ -370,8 +370,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) } else { if (smk->stream_id[smk->curstream] < 0 || !smk->bufs[smk->curstream]) return AVERROR_INVALIDDATA; - if (av_new_packet(pkt, smk->buf_sizes[smk->curstream])) - return AVERROR(ENOMEM); + if ((ret = av_new_packet(pkt, smk->buf_sizes[smk->curstream])) < 0) + return ret; memcpy(pkt->data, smk->bufs[smk->curstream], smk->buf_sizes[smk->curstream]); pkt->size = smk->buf_sizes[smk->curstream]; pkt->stream_index = smk->stream_id[smk->curstream]; |