[FFmpeg-devel] [PATCHv2] avformat/mp3dec, rmdec: check return value of ffio_ensure_seekback
Ganesh Ajjanagadde
gajjanagadde at gmail.com
Tue Nov 17 23:39:31 CET 2015
ffio_ensure_seekback can fail due to e.g ENOMEM. This return value is
checked here and a diagnostic is logged.
All usage of ffio_ensure_seekback in the codebase now has the return value checked.
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
libavformat/mp3dec.c | 6 ++++--
libavformat/rmdec.c | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 32ca00c..a14bccd 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -380,11 +380,13 @@ static int mp3_read_header(AVFormatContext *s)
uint32_t header, header2;
int frame_size;
if (!(i&1023))
- ffio_ensure_seekback(s->pb, i + 1024 + 4);
+ if ((ret = ffio_ensure_seekback(s->pb, i + 1024 + 4)) < 0)
+ av_log(s, AV_LOG_WARNING, "ffio_ensure_seekback(): %s\n", av_err2str(ret));
frame_size = check(s->pb, off + i, &header);
if (frame_size > 0) {
avio_seek(s->pb, off, SEEK_SET);
- ffio_ensure_seekback(s->pb, i + 1024 + frame_size + 4);
+ if ((ret = ffio_ensure_seekback(s->pb, i + 1024 + frame_size + 4)) < 0)
+ av_log(s, AV_LOG_WARNING, "ffio_ensure_seekback(): %s\n", av_err2str(ret));
if (check(s->pb, off + i + frame_size, &header2) >= 0 &&
(header & SAME_HEADER_MASK) == (header2 & SAME_HEADER_MASK))
{
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 4ec78ef..1cf0548 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -576,7 +576,8 @@ static int rm_read_header(AVFormatContext *s)
size = avio_rb32(pb);
codec_pos = avio_tell(pb);
- ffio_ensure_seekback(pb, 4);
+ if ((ret = ffio_ensure_seekback(pb, 4)) < 0)
+ av_log(s, AV_LOG_WARNING, "ffio_ensure_seekback(): %s\n", av_err2str(ret));
v = avio_rb32(pb);
if (v == MKBETAG('M', 'L', 'T', 'I')) {
int number_of_streams = avio_rb16(pb);
--
2.6.2
More information about the ffmpeg-devel
mailing list