Maybe

"mov: Do not set stsd_count if mov_read_stsd fails"
And make sure the patch actually does that by checking all the fail paths.
Probably ok.


On 30/07/2017 01:18, Sean McGovern wrote:
> Based on an FFmpeg patch by Michael Niedermayer <[email protected]>
> ---
>  libavformat/mov.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 8ff6022..e56b8e9 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1891,15 +1891,18 @@ static int mov_read_stsd(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>      if (!sc->extradata)
>          return AVERROR(ENOMEM);
>  
> -    sc->stsd_count = entries;
> -    sc->extradata_size = av_mallocz_array(sc->stsd_count, 
> sizeof(*sc->extradata_size));
> -    if (!sc->extradata_size)
> -        return AVERROR(ENOMEM);
> +    sc->extradata_size = av_mallocz_array(entries, 
> sizeof(*sc->extradata_size));
> +    if (!sc->extradata_size) {
> +        ret = AVERROR(ENOMEM);
> +        goto fail;
> +    }
>  
> -    ret = ff_mov_read_stsd_entries(c, pb, sc->stsd_count);
> +    ret = ff_mov_read_stsd_entries(c, pb, entries);
>      if (ret < 0)
>          return ret;
>  
> +    sc->stsd_count = entries;
> +
>      /* Restore back the primary extradata. */
>      av_free(st->codecpar->extradata);
>      st->codecpar->extradata_size = sc->extradata_size[0];
> @@ -1909,6 +1912,10 @@ static int mov_read_stsd(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>      memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]);
>  
>      return 0;
> +fail:
> +    av_freep(&sc->extradata);
> +    av_freep(&sc->extradata_size);
> +    return ret;
>  }
>  
>  static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> 

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to