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/fsb.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/fsb.c')
-rw-r--r-- | libavformat/fsb.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libavformat/fsb.c b/libavformat/fsb.c index faad6b16fd..fd3e484371 100644 --- a/libavformat/fsb.c +++ b/libavformat/fsb.c @@ -41,6 +41,7 @@ static int fsb_read_header(AVFormatContext *s) int64_t offset; AVCodecParameters *par; AVStream *st = avformat_new_stream(s, NULL); + int ret; avio_skip(pb, 3); // "FSB" version = avio_r8(pb) - '0'; @@ -86,9 +87,9 @@ static int fsb_read_header(AVFormatContext *s) par->block_align = 8 * par->channels; if (par->channels > INT_MAX / 32) return AVERROR_INVALIDDATA; - ff_alloc_extradata(par, 32 * par->channels); - if (!par->extradata) - return AVERROR(ENOMEM); + ret = ff_alloc_extradata(par, 32 * par->channels); + if (ret < 0) + return ret; avio_seek(pb, 0x68, SEEK_SET); for (c = 0; c < par->channels; c++) { avio_read(pb, par->extradata + 32 * c, 32); @@ -130,18 +131,18 @@ static int fsb_read_header(AVFormatContext *s) switch (par->codec_id) { case AV_CODEC_ID_XMA2: - ff_alloc_extradata(par, 34); - if (!par->extradata) - return AVERROR(ENOMEM); + ret = ff_alloc_extradata(par, 34); + if (ret < 0) + return ret; memset(par->extradata, 0, 34); par->block_align = 2048; break; case AV_CODEC_ID_ADPCM_THP: if (par->channels > INT_MAX / 32) return AVERROR_INVALIDDATA; - ff_alloc_extradata(par, 32 * par->channels); - if (!par->extradata) - return AVERROR(ENOMEM); + ret = ff_alloc_extradata(par, 32 * par->channels); + if (ret < 0) + return ret; avio_seek(pb, 0x80, SEEK_SET); for (c = 0; c < par->channels; c++) { avio_read(pb, par->extradata + 32 * c, 32); |