[libav-devel] [PATCH] ogg: check malloc calls

Timothy Gu timothygu99 at gmail.com
Sun Jun 1 15:56:28 CEST 2014


On Jun 1, 2014 5:30 AM, "Nidhi Makhijani" <nidhimj22 at gmail.com> wrote:
>
> ---
>  libavformat/oggparsespeex.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
> index 6d70e99..df2bd6c 100644
> --- a/libavformat/oggparsespeex.c
> +++ b/libavformat/oggparsespeex.c
> @@ -47,6 +47,8 @@ static int speex_header(AVFormatContext *s, int idx) {
>
>      if (!spxp) {
>          spxp = av_mallocz(sizeof(*spxp));
> +        if (!spxp)
> +            return AVERROR(ENOMEM);
>          os->private = spxp;
>      }
>
> @@ -75,6 +77,10 @@ static int speex_header(AVFormatContext *s, int idx) {
>          st->codec->extradata_size = os->psize;
>          st->codec->extradata = av_malloc(st->codec->extradata_size
>                                           + FF_INPUT_BUFFER_PADDING_SIZE);
> +        if (!st->codec->extradata) {

> +            av_freep(spxp);

av_freep(&spxp);

> +            return AVERROR(ENOMEM);
> +        }
>          memcpy(st->codec->extradata, p, st->codec->extradata_size);
>
>          avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
> --
> 1.9.1
>
> _______________________________________________
> libav-devel mailing list
> libav-devel at libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel


More information about the libav-devel mailing list