[libav-devel] [PATCH 2/3] avformat/matroskadec: Call matroska_read_close() on header parsing error

Vittorio Giovara vittorio.giovara at gmail.com
Thu Nov 2 16:19:05 CET 2017


On Wed, Nov 1, 2017 at 10:10 PM, Sean McGovern <gseanmcg at gmail.com> wrote:

> From: Michael Niedermayer <michael at niedermayer.cc>
>
> Fixes memleak
>

nit full stop

Fixes Ticket5169
>

Please use the syntax "Bug-Id: ffmpeg/Ticket5169".


> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>  libavformat/matroskadec.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 3743d4d..9c523fb 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -592,6 +592,8 @@ static EbmlSyntax matroska_clusters_incremental[] = {
>
>  static const char *const matroska_doctypes[] = { "matroska", "webm" };
>
> +static int matroska_read_close(AVFormatContext *s);
> +
>

if possible there should be a separate patch that moves matroska_read_close
here, rather than introducing a forward statement.


>  static int matroska_resync(MatroskaDemuxContext *matroska, int64_t
> last_pos)
>  {
>      AVIOContext *pb = matroska->ctx->pb;
> @@ -2099,7 +2101,7 @@ static int matroska_read_header(AVFormatContext *s)
>      while (res != 1) {
>          res = matroska_resync(matroska, pos);
>          if (res < 0)
> -            return res;
> +            goto fail;
>          pos = avio_tell(matroska->ctx->pb);
>          res = ebml_parse(matroska, matroska_segment, matroska);
>      }
> @@ -2114,7 +2116,7 @@ static int matroska_read_header(AVFormatContext *s)
>
>      res = matroska_parse_tracks(s);
>      if (res < 0)
> -        return res;
> +        goto fail;
>
>      attachments = attachments_list->elem;
>      for (j = 0; j < attachments_list->nb_elem; j++) {
> @@ -2187,6 +2189,9 @@ static int matroska_read_header(AVFormatContext *s)
>      matroska_convert_tags(s);
>
>      return 0;
> +fail:
> +    matroska_read_close(s);
> +    return res;
>  }
>
> --
Vittorio


More information about the libav-devel mailing list