diff options
author | nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-11-02 20:06:28 +0000 |
---|---|---|
committer | nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-11-02 20:06:28 +0000 |
commit | 89a5add7946b62896effebc44ce3b74a719ee495 (patch) | |
tree | 7af74909c649a9ff03b3d11557cacc49e33c11fb /libmpdemux | |
parent | a5541ee85b37f78611cd945992862c9c2e512dca (diff) |
prevent unlikely memleak
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24938 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/muxer_mpeg.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libmpdemux/muxer_mpeg.c b/libmpdemux/muxer_mpeg.c index 0ad1015f92..9df090dd0b 100644 --- a/libmpdemux/muxer_mpeg.c +++ b/libmpdemux/muxer_mpeg.c @@ -2348,17 +2348,20 @@ static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags if(s->b_buffer_size - s->b_buffer_len < len) { + void *tmp; + if(s->b_buffer_len > SIZE_MAX - len) { mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc, integer overflow\n"); return; } - s->b_buffer = realloc(s->b_buffer, len + s->b_buffer_len); - if(s->b_buffer == NULL) + tmp = realloc(s->b_buffer, len + s->b_buffer_len); + if(!tmp) { mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc %d bytes\n", len + s->b_buffer_len); return; } + s->b_buffer = tmp; s->b_buffer_size = len + s->b_buffer_len; mp_msg(MSGT_MUXER, MSGL_DBG2, "REALLOC(%d) bytes to AUDIO backbuffer\n", s->b_buffer_size); |