diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-02-12 09:28:09 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-02-12 09:28:09 +0000 |
commit | 7bb8f38da891da9ae91e8714719235fff6d18edd (patch) | |
tree | d0cae995e568f2c7a120375158dc8ce59989e679 /libmpdemux | |
parent | 3407748cf8c9549dbc1b345398d268a86b466aab (diff) | |
download | mpv-7bb8f38da891da9ae91e8714719235fff6d18edd.tar.bz2 mpv-7bb8f38da891da9ae91e8714719235fff6d18edd.tar.xz |
add some sanity checks to new/resize_demux_packet
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17598 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demuxer.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h index e184280b40..7477bad5cc 100644 --- a/libmpdemux/demuxer.h +++ b/libmpdemux/demuxer.h @@ -190,17 +190,18 @@ inline static demux_packet_t* new_demux_packet(int len){ 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 @@ inline static void resize_demux_packet(demux_packet_t* dp, int len) 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){ |