[asterisk-commits] russell: trunk r41944 - /trunk/main/utils.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Sep 3 15:56:01 MST 2006


Author: russell
Date: Sun Sep  3 17:56:01 2006
New Revision: 41944

URL: http://svn.digium.com/view/asterisk?rev=41944&view=rev
Log:
when calling this function to append to a dynamic string and the buffer was not
large enough and had to be reallocated, cut off the partially appended data.
Otherwise, the function will get called over and over again appending to the
end every time and never thinking it has enough room.

Thanks to jmls for access to his machine for debugging!

(issue #7691)

Modified:
    trunk/main/utils.c

Modified: trunk/main/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/main/utils.c?rev=41944&r1=41943&r2=41944&view=diff
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Sun Sep  3 17:56:01 2006
@@ -1219,6 +1219,9 @@
 		if (!(*buf = ast_realloc(*buf, (*buf)->len + sizeof(*(*buf)))))
 			return AST_DYNSTR_BUILD_FAILED;
 
+		if (append)
+			(*buf)->str[offset] = '\0';
+
 		if (ts)
 			pthread_setspecific(ts->key, *buf);
 



More information about the asterisk-commits mailing list