# HG changeset patch # User reimar # Date 1139736489 0 # Node ID a3a4f7408f9006163c84cdd73b83f477c65333c9 # Parent 52fb9a8bf702bb68cdc9402ab73941e623895140 add some sanity checks to new/resize_demux_packet diff -r 52fb9a8bf702 -r a3a4f7408f90 libmpdemux/demuxer.h --- a/libmpdemux/demuxer.h Sun Feb 12 08:03:58 2006 +0000 +++ b/libmpdemux/demuxer.h Sun Feb 12 09:28:09 2006 +0000 @@ -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){