[MPlayer-cvslog] r32831 - trunk/libmpdemux/demuxer.h

reimar subversion at mplayerhq.hu
Sun Jan 30 11:35:00 CET 2011


Author: reimar
Date: Sun Jan 30 11:35:00 2011
New Revision: 32831

Log:
Make new_demux_packet return NULL if allocation failed, this should
ease checking for failure in code and where those checks are missing
it should ensure crashes instead of possibly exploitable code.

Modified:
   trunk/libmpdemux/demuxer.h

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	Sun Jan 30 11:27:31 2011	(r32830)
+++ trunk/libmpdemux/demuxer.h	Sun Jan 30 11:35:00 2011	(r32831)
@@ -294,8 +294,11 @@ static inline demux_packet_t* new_demux_
   dp->buffer=NULL;
   if (len > 0 && (dp->buffer = (unsigned char *)malloc(len + MP_INPUT_BUFFER_PADDING_SIZE)))
     memset(dp->buffer + len, 0, MP_INPUT_BUFFER_PADDING_SIZE);
-  else
-    dp->len = 0;
+  else if (len) {
+    // do not even return a valid packet if allocation failed
+    free(dp);
+    return NULL;
+  }
   return dp;
 }
 


More information about the MPlayer-cvslog mailing list