Mercurial > mplayer.hg
changeset 32744:c8475dec7a3f
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.
author | reimar |
---|---|
date | Sun, 30 Jan 2011 10:35:00 +0000 |
parents | 9b590f58634c |
children | 64be018ebafa |
files | libmpdemux/demuxer.h |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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; }