[FFmpeg-devel] [PATCHv2] avformat/mp3dec, rmdec: check return value of ffio_ensure_seekback

Michael Niedermayer michaelni at gmx.at
Fri Nov 20 17:50:09 CET 2015


On Tue, Nov 17, 2015 at 05:39:31PM -0500, Ganesh Ajjanagadde wrote:
> 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))
>              {

it is probably better to also break out of the loop if these fail

and as a message yu could use something like
initial junk detection and skiping not possible due to <error>

[....]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151120/65bc0e30/attachment.sig>


More information about the ffmpeg-devel mailing list