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/dxa.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/dxa.c')
-rw-r--r-- | libavformat/dxa.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libavformat/dxa.c b/libavformat/dxa.c index 298cda05d7..994078e633 100644 --- a/libavformat/dxa.c +++ b/libavformat/dxa.c @@ -179,8 +179,8 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) tag = AV_RL32(buf); switch (tag) { case MKTAG('N', 'U', 'L', 'L'): - if(av_new_packet(pkt, 4 + pal_size) < 0) - return AVERROR(ENOMEM); + if ((ret = av_new_packet(pkt, 4 + pal_size)) < 0) + return ret; pkt->stream_index = 0; if(pal_size) memcpy(pkt->data, pal, pal_size); memcpy(pkt->data + pal_size, buf, 4); @@ -204,8 +204,9 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) size); return AVERROR_INVALIDDATA; } - if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0) - return AVERROR(ENOMEM); + ret = av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size); + if (ret < 0) + return ret; memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE); ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size); if(ret != size){ |