[Mplayer-cvslog] CVS: main/libmpdemux demux_mov.c,1.53,1.54 parse_mp4.c,1.1,1.2

Atmosfear atmos4 at mplayer.dev.hu
Sun Mar 24 04:07:21 CET 2002


Update of /cvsroot/mplayer/main/libmpdemux
In directory mplayer:/var/tmp.root/cvs-serv19645/libmpdemux

Modified Files:
	demux_mov.c parse_mp4.c 
Log Message:
10l fix memory allocation


Index: demux_mov.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mov.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- demux_mov.c	24 Mar 2002 02:38:20 -0000	1.53
+++ demux_mov.c	24 Mar 2002 03:07:18 -0000	1.54
@@ -707,7 +707,7 @@
 			mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len);
 			if(atom_len >= 8) {
 			  esds_t *esds = (esds_t *)malloc(sizeof(esds_t)); 				  
-			  if(!mp4_parse_esds(&trak->stdata[36], atom_len-8, esds)) {
+			  if(esds && !mp4_parse_esds(&trak->stdata[36], atom_len-8, esds)) {
 			    
 			    sh->i_bps = esds->avgBitrate/8; 
 
@@ -716,7 +716,11 @@
 			    sh->codecdata = (unsigned char *)malloc(sh->codecdata_len);
 			    memcpy(sh->codecdata, esds->decoderConfig, sh->codecdata_len);
 			  }
-			  free(esds);
+			  if(esds) {
+			    if(esds->decoderConfig)
+			      free(esds->decoderConfig);
+			    free(esds);
+			  }
 #if 0
 	  		  { FILE* f=fopen("esds.dat","wb");
 			  fwrite(&trak->stdata[36],atom_len-8,1,f);

Index: parse_mp4.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/parse_mp4.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- parse_mp4.c	24 Mar 2002 02:25:41 -0000	1.1
+++ parse_mp4.c	24 Mar 2002 03:07:18 -0000	1.2
@@ -13,6 +13,7 @@
 #include "stream.h"
 
 #define MP4_DL MSGL_V
+#define freereturn(a,b) free(a); return b
 
 int mp4_read_descr_len(stream_t *s) {
   uint8_t b;
@@ -45,7 +46,7 @@
   if (tag == MP4ESDescrTag) {
     /* read length */
     if ((len = mp4_read_descr_len(s)) < 5 + 15) {
-      return 1;
+      freereturn(s,1);
     }
     esds->ESId = stream_read_word(s);
     esds->streamPriority = stream_read_char(s);
@@ -65,12 +66,12 @@
 
   /* get and verify DecoderConfigDescrTab */
   if (stream_read_char(s) != MP4DecConfigDescrTag) {
-    return 1;
+    freereturn(s,1);
   }
 
   /* read length */
   if ((len = mp4_read_descr_len(s)) < 15) {
-    return 1;
+    freereturn(s,1);
   }
 
   esds->objectTypeId = stream_read_char(s);
@@ -91,13 +92,12 @@
 
   /* get and verify DecSpecificInfoTag */
   if (stream_read_char(s) != MP4DecSpecificDescrTag) {
-    return 1;
+    freereturn(s,1);
   }
 
   /* read length */
   esds->decoderConfigLen = len = mp4_read_descr_len(s); 
 
-  free(esds->decoderConfig);
   esds->decoderConfig = malloc(esds->decoderConfigLen);
   if (esds->decoderConfig) {
     stream_read(s, esds->decoderConfig, esds->decoderConfigLen);
@@ -108,7 +108,10 @@
       "ESDS MPEG4 Decoder Specific Descriptor (%dBytes)\n", len);
 
   /* will skip the remainder of the atom */
-  return 0;
+  freereturn(s,0);
 
 }
+
+#undef freereturn
+#undef MP4_DL
 




More information about the MPlayer-cvslog mailing list