OSDN Git Service

mov: do not misreport empty stts
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 11 Oct 2011 08:14:06 +0000 (10:14 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Tue, 11 Oct 2011 13:06:50 +0000 (15:06 +0200)
Return -1 instead of ENOMEM if entries is 0.
Fixes a av_malloc(0) crash in macosx.

libavformat/mov.c

index 4f5bb0c..0e2ad1f 100644 (file)
@@ -1461,8 +1461,8 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     av_dlog(c->fc, "track[%i].stts.entries = %i\n",
             c->fc->nb_streams-1, entries);
 
-    if (entries >= UINT_MAX / sizeof(*sc->stts_data))
-        return -1;
+    if (!entries || entries >= UINT_MAX / sizeof(*sc->stts_data))
+        return AVERROR(EINVAL);
 
     sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));
     if (!sc->stts_data)