]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a problem that showed itself by causing Zap channel names to be completely
authorRussell Bryant <russell@russellbryant.com>
Tue, 5 Jun 2007 16:56:36 +0000 (16:56 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 5 Jun 2007 16:56:36 +0000 (16:56 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@67360 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c

index d830f1f8b39fa57ff6a7a5726bf6ac9e1f970b43..71214a0e4593ad1120d94c5d929e0d43f870ac91 100644 (file)
@@ -427,15 +427,20 @@ static int ast_check_hangup_locked(struct ast_channel *chan)
 /*! \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;
 }