# HG changeset patch # User reimar # Date 1296383700 0 # Node ID c8475dec7a3f7afe95323768b1acf0f2a0d81971 # Parent 9b590f58634c74416a5217b760e1ee9717b09c06 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. diff -r 9b590f58634c -r c8475dec7a3f libmpdemux/demuxer.h --- a/libmpdemux/demuxer.h Sun Jan 30 10:27:31 2011 +0000 +++ b/libmpdemux/demuxer.h Sun Jan 30 10:35:00 2011 +0000 @@ -294,8 +294,11 @@ 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; }