aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/4xm.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-01-07 14:55:44 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-01-08 01:32:26 +0100
commit45e7c67affb57f0286fc111e61686025f4ef4a04 (patch)
treec00b4d1c671acb6f59837c2f41064340ed5a862e /libavformat/4xm.c
parentbb20f3dd730689c3a99f7820cff8b74b06992fff (diff)
downloadffmpeg-45e7c67affb57f0286fc111e61686025f4ef4a04.tar.gz
avformat: Improve returned error codes
This commit improves returned error codes by forwarding error codes. In some instances, the hardcoded returned error codes made no sense at all: The normal error code for failure of av_new_packet() is AVERROR(ENOMEM), yet there were instances where AVERROR(EIO) was returned. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/4xm.c')
-rw-r--r--libavformat/4xm.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index a6101a92ec..aea9226984 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -322,8 +322,10 @@ static int fourxm_read_packet(AVFormatContext *s,
case cfr2_TAG:
/* allocate 8 more bytes than 'size' to account for fourcc
* and size */
- if (size + 8 < size || av_new_packet(pkt, size + 8))
- return AVERROR(EIO);
+ if (size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 8)
+ return AVERROR_INVALIDDATA;
+ if ((ret = av_new_packet(pkt, size + 8)) < 0)
+ return ret;
pkt->stream_index = fourxm->video_stream_index;
pkt->pts = fourxm->video_pts;
pkt->pos = avio_tell(s->pb);
@@ -347,7 +349,7 @@ static int fourxm_read_packet(AVFormatContext *s,
fourxm->tracks[track_number].channels > 0) {
ret = av_get_packet(s->pb, pkt, size);
if (ret < 0)
- return AVERROR(EIO);
+ return ret;
pkt->stream_index =
fourxm->tracks[track_number].stream_index;
pkt->pts = fourxm->tracks[track_number].audio_pts;