[asterisk-commits] russell: branch 1.4 r67360 - /branches/1.4/main/channel.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jun 5 09:56:36 MST 2007


Author: russell
Date: Tue Jun  5 11:56:36 2007
New Revision: 67360

URL: http://svn.digium.com/view/asterisk?view=rev&rev=67360
Log:
Fix a problem that showed itself by causing Zap channel names to be completely
bogus on my machine.  ast_safe_string_alloc() was broken.  It called 
vsnprintf() on a va_args list twice without re-initializing it.  After the first
usage, va_end() and va_start() must be called again.

Modified:
    branches/1.4/main/channel.c

Modified: branches/1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/channel.c?view=diff&rev=67360&r1=67359&r2=67360
==============================================================================
--- branches/1.4/main/channel.c (original)
+++ branches/1.4/main/channel.c Tue Jun  5 11:56:36 2007
@@ -427,15 +427,20 @@
 /*! \brief printf the string into a correctly sized mallocd buffer, and return the buffer */
 char *ast_safe_string_alloc(const char *fmt, ...)
 {
-	char *b2,buf[1];
+	char *b2, buf[1];
 	int len;
-
 	va_list args;
+
 	va_start(args, fmt);
 	len = vsnprintf(buf, 1, fmt, args);
-	b2 = ast_malloc(len+1);
-	vsnprintf(b2, len+1,  fmt, args);
 	va_end(args);
+
+	b2 = ast_malloc(len + 1);
+
+	va_start(args, fmt);
+	vsnprintf(b2, len + 1,  fmt, args);
+	va_end(args);
+
 	return b2;
 }
 



More information about the asterisk-commits mailing list