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

Freeswitch SVN anthm at freeswitch.org
Sat Nov 11 14:40:42 EST 2006


Author: anthm
Date: Sat Nov 11 14:40:41 2006
New Revision: 3316

Modified:
   freeswitch/trunk/src/switch_event.c

Log:
let's make sure realloc works

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Sat Nov 11 14:40:41 2006
@@ -615,8 +615,14 @@
 		llen = strlen(hp->name) + strlen(hp->value) + 2;
 		
 		if ((len + llen) > dlen) {
+			char *m;
 			dlen += (blocksize + (len + llen));
-			buf = realloc(buf, dlen);
+			if ((m = realloc(buf, dlen))) {
+				buf = m;
+			} else {
+				switch_safe_free(buf);
+				return SWITCH_STATUS_MEMERR;
+			}
 		}
 
 		snprintf(buf + len, dlen - len, "%s: %s\n", hp->name, hp->value);
@@ -634,10 +640,16 @@
 		}
 		
 		if ((len + llen) > dlen) {
+			char *m;
 			dlen += (blocksize + (len + llen));
-			buf = realloc(buf, dlen);
+			if ((m = realloc(buf, dlen))) {
+				buf = m;
+			} else {
+				switch_safe_free(buf);
+				return SWITCH_STATUS_MEMERR;
+			}
 		}
-
+		
 		if (blen) {
 			snprintf(buf + len, dlen - len, "Content-Length: %d\n\n%s", blen, event->body);
 		} else {



More information about the Freeswitch-svn mailing list