[Freeswitch-svn] [commit] r9135 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Tue Jul 22 14:48:57 EDT 2008


Author: anthm
Date: Tue Jul 22 14:48:56 2008
New Revision: 9135

Modified:
   freeswitch/trunk/src/switch_buffer.c

Log:
don't leak on realloc fail

Modified: freeswitch/trunk/src/switch_buffer.c
==============================================================================
--- freeswitch/trunk/src/switch_buffer.c	(original)
+++ freeswitch/trunk/src/switch_buffer.c	Tue Jul 22 14:48:56 2008
@@ -229,6 +229,7 @@
 	if (switch_test_flag(buffer, SWITCH_BUFFER_FLAG_DYNAMIC)) {
 		if (freespace < datalen && (!buffer->max_len || (buffer->used + datalen <= buffer->max_len))) {
 			switch_size_t new_size, new_block_size;
+			void *data;
 
 			new_size = buffer->datalen + datalen;
 			new_block_size = buffer->datalen + buffer->blocksize;
@@ -237,9 +238,10 @@
 				new_size = new_block_size;
 			}
 			buffer->head = buffer->data;
-			if (!(buffer->data = realloc(buffer->data, new_size))) {
+			if (!(data = realloc(buffer->data, new_size))) {
 				return 0;
 			}
+			buffer->data = data;
 			buffer->head = buffer->data;
 			buffer->datalen = new_size;
 		}



More information about the Freeswitch-svn mailing list