[MPlayer-cvslog] CVS: main/libmpdemux demuxer.h,1.87,1.88

Reimar Döffinger CVS syncmail at mplayerhq.hu
Sun Feb 12 10:28:12 CET 2006


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv27767

Modified Files:
	demuxer.h 
Log Message:
add some sanity checks to new/resize_demux_packet


Index: demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -r1.87 -r1.88
--- demuxer.h	9 Feb 2006 19:39:51 -0000	1.87
+++ demuxer.h	12 Feb 2006 09:28:09 -0000	1.88
@@ -190,17 +190,18 @@
   dp->flags=0;
   dp->refcount=1;
   dp->master=NULL;
-  dp->buffer=len?(unsigned char*)malloc(len+8):NULL;
-  if(len) memset(dp->buffer+len,0,8);
+  if (len > 0 && (dp->buffer = malloc(len + 8)))
+    memset(dp->buffer + len, 0, 8);
+  else
+    dp->len = 0;
   return dp;
 }
 
 inline static void resize_demux_packet(demux_packet_t* dp, int len)
 {
-  if(len)
+  if(len > 0)
   {
      dp->buffer=(unsigned char *)realloc(dp->buffer,len+8);
-     memset(dp->buffer+len,0,8);
   }
   else
   {
@@ -208,6 +209,10 @@
      dp->buffer=NULL;
   }
   dp->len=len;
+  if (dp->buffer)
+     memset(dp->buffer + len, 0, 8);
+  else
+     dp->len = 0;
 }
 
 inline static demux_packet_t* clone_demux_packet(demux_packet_t* pack){




More information about the MPlayer-cvslog mailing list