aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mm.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-10 22:59:53 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2019-12-12 19:25:33 +0100
commitc1e439d7e9abab3cebdc937636393b1656e095d9 (patch)
treebe0ae941a23b62c42b152e2b9aa0a22f8c793d4e /libavformat/mm.c
parentcb88cdf7730e309df22ddbbc1ae4ebcd9ebc529e (diff)
downloadffmpeg-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/mm.c')
-rw-r--r--libavformat/mm.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavformat/mm.c b/libavformat/mm.c
index 83b3c200c6..d40fd12acc 100644
--- a/libavformat/mm.c
+++ b/libavformat/mm.c
@@ -142,6 +142,7 @@ static int read_packet(AVFormatContext *s,
AVIOContext *pb = s->pb;
unsigned char preamble[MM_PREAMBLE_SIZE];
unsigned int type, length;
+ int ret;
while(1) {
@@ -161,8 +162,8 @@ static int read_packet(AVFormatContext *s,
case MM_TYPE_INTRA_HHV :
case MM_TYPE_INTER_HHV :
/* output preamble + data */
- if (av_new_packet(pkt, length + MM_PREAMBLE_SIZE))
- return AVERROR(ENOMEM);
+ if ((ret = av_new_packet(pkt, length + MM_PREAMBLE_SIZE)) < 0)
+ return ret;
memcpy(pkt->data, preamble, MM_PREAMBLE_SIZE);
if (avio_read(pb, pkt->data + MM_PREAMBLE_SIZE, length) != length)
return AVERROR(EIO);
@@ -174,8 +175,8 @@ static int read_packet(AVFormatContext *s,
return 0;
case MM_TYPE_AUDIO :
- if (av_get_packet(s->pb, pkt, length)<0)
- return AVERROR(ENOMEM);
+ if ((ret = av_get_packet(s->pb, pkt, length)) < 0)
+ return ret;
pkt->stream_index = 1;
pkt->pts = mm->audio_pts++;
return 0;