[asterisk-commits] murf: trunk r89051 - in /trunk/main: ast_expr2.fl ast_expr2f.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 6 13:40:33 CST 2007


Author: murf
Date: Tue Nov  6 13:40:33 2007
New Revision: 89051

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89051
Log:
Hoping to avoid a crash in OSX for a problem blitzrage found

Modified:
    trunk/main/ast_expr2.fl
    trunk/main/ast_expr2f.c

Modified: trunk/main/ast_expr2.fl
URL: http://svn.digium.com/view/asterisk/trunk/main/ast_expr2.fl?view=diff&rev=89051&r1=89050&r2=89051
==============================================================================
--- trunk/main/ast_expr2.fl (original)
+++ trunk/main/ast_expr2.fl Tue Nov  6 13:40:33 2007
@@ -264,13 +264,17 @@
 			res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i);
 			return_value = (res_length <= length) ? res_length : length;
 		} else {
+			if (io.val->u.s)
 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
-			strncpy(buf, io.val->u.s, length - 1);
+				strncpy(buf, io.val->u.s, length - 1);
 #else /* !STANDALONE && !LOW_MEMORY */
-			ast_copy_string(buf, io.val->u.s, length);
+				ast_copy_string(buf, io.val->u.s, length);
 #endif /* STANDALONE || LOW_MEMORY */
+			else
+				buf[0] = 0;
 			return_value = strlen(buf);
-			free(io.val->u.s);
+			if (io.val->u.s)
+				free(io.val->u.s);
 		}
 		free(io.val);
 	}

Modified: trunk/main/ast_expr2f.c
URL: http://svn.digium.com/view/asterisk/trunk/main/ast_expr2f.c?view=diff&rev=89051&r1=89050&r2=89051
==============================================================================
--- trunk/main/ast_expr2f.c (original)
+++ trunk/main/ast_expr2f.c Tue Nov  6 13:40:33 2007
@@ -3207,13 +3207,17 @@
 			res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i);
 			return_value = (res_length <= length) ? res_length : length;
 		} else {
+			if (io.val->u.s)
 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
-			strncpy(buf, io.val->u.s, length - 1);
+				strncpy(buf, io.val->u.s, length - 1);
 #else /* !STANDALONE && !LOW_MEMORY */
-			ast_copy_string(buf, io.val->u.s, length);
+				ast_copy_string(buf, io.val->u.s, length);
 #endif /* STANDALONE || LOW_MEMORY */
+			else
+				buf[0] = 0;
 			return_value = strlen(buf);
-			free(io.val->u.s);
+			if (io.val->u.s)
+				free(io.val->u.s);
 		}
 		free(io.val);
 	}




More information about the asterisk-commits mailing list