[libav-stable] flvdec: Check the return value of a malloc

Reinhard Tartler siretart at tauware.de
Sat Mar 2 08:26:52 CET 2013


On Fr, Mär 01, 2013 at 23:41:25 (CET), Martin Storsjö  wrote:

> Module: libav
> Branch: master
> Commit: c5a738ca4e9789b4678b10240777d931e7dc24c9
>
> Author:    Martin Storsjö <martin at martin.st>
> Committer: Martin Storsjö <martin at martin.st>
> Date:      Fri Mar  1 16:45:24 2013 +0200
>
> flvdec: Check the return value of a malloc
>
> The callers of this function can't report errors sanely. If this
> one malloc fails, don't write the extradata byte, make sure we
> try to malloc it the next time we're called instead, and make sure
> we still consume the input data byte.
>
> CC: libav-stable at libav.org
> Signed-off-by: Martin Storsjö <martin at martin.st>
>
> ---
>
>  libavformat/flvdec.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index e45a9a2..403a9b5 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -213,10 +213,14 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_co
>                  vcodec->codec_id = AV_CODEC_ID_VP6A;
>              if (read) {
>                  if (vcodec->extradata_size != 1) {
> -                    vcodec->extradata_size = 1;
>                      vcodec->extradata = av_malloc(1);
> +                    if (vcodec->extradata)
> +                        vcodec->extradata_size = 1;
>                  }
> -                vcodec->extradata[0] = avio_r8(s->pb);
> +                if (vcodec->extradata)
> +                    vcodec->extradata[0] = avio_r8(s->pb);
> +                else
> +                    avio_skip(s->pb, 1);
>              }
>              return 1; // 1 byte body size adjustment for flv_read_packet()
>          case FLV_CODECID_H264:

OK for stable
-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4


More information about the libav-stable mailing list