mov: fix leaking memory with multiple drefs.

Instead of allocating over the original, free first. MOVStreamContext
is zero initialized so no double free will occur. Same style as other
fixes for the same problem in this file.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
pull/5/head
Dale Curtis 13 years ago committed by Luca Barbato
parent 7f77e9041a
commit 4ebd422c04
  1. 1
      libavformat/mov.c

@ -387,6 +387,7 @@ static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
entries = avio_rb32(pb); entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->drefs)) if (entries >= UINT_MAX / sizeof(*sc->drefs))
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
av_free(sc->drefs);
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs)); sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
if (!sc->drefs) if (!sc->drefs)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);

Loading…
Cancel
Save