[MPlayer-dev-eng] [PATCH] extra checks for mov sample size

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Aug 27 14:16:57 CEST 2005


Hi,
the attached patch should prevent crashes in some very rare cases.
Does it look okay to you? I intend to apply tomorrow.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_mov.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mov.c,v
retrieving revision 1.126
diff -u -r1.126 demux_mov.c
--- libmpdemux/demux_mov.c	5 Aug 2005 19:57:46 -0000	1.126
+++ libmpdemux/demux_mov.c	27 Aug 2005 12:15:01 -0000
@@ -194,6 +194,14 @@
         trak->chunks[j].sample=s;
         s+=trak->chunks[j].size;
     }
+    i = 0;
+    for (j = 0; j < trak->durmap_size; j++)
+      i += trak->durmap[j].num;
+    if (i != s) {
+      mp_msg(MSGT_DEMUX, MSGL_WARN,
+             "MOV: durmap and chunkmap sample count differ (%i vs %i)\n", i, s);
+      if (i > s) s = i;
+    }
 
     // workaround for fixed-size video frames (dv and uncompressed)
     if(!trak->samples_size && trak->type!=MOV_TRAK_AUDIO){
@@ -212,6 +220,14 @@
 	return;
     }
     
+    if (trak->samples_size < s) {
+      mp_msg(MSGT_DEMUX, MSGL_WARN,
+             "MOV: durmap or chunkmap bigger than sample count (%i vs %i)\n",
+             s, trak->samples_size);
+      trak->samples_size = s;
+      trak->samples = realloc(trak->samples, sizeof(mov_sample_t) * s);
+    }
+
     // calc pts:
     s=0;
     for(j=0;j<trak->durmap_size;j++){


More information about the MPlayer-dev-eng mailing list