changeset 24910:74ae00838094

prevent unlikely memleak
author nicodvb
date Fri, 02 Nov 2007 20:06:28 +0000
parents 55c96e871198
children 475c585b0c77
files libmpdemux/muxer_mpeg.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/muxer_mpeg.c	Fri Nov 02 19:52:22 2007 +0000
+++ b/libmpdemux/muxer_mpeg.c	Fri Nov 02 20:06:28 2007 +0000
@@ -2348,17 +2348,20 @@
 		
 		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);