[svn-commits] tilghman: trunk r176360 - /trunk/main/strings.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Feb 16 17:48:54 CST 2009
Author: tilghman
Date: Mon Feb 16 17:48:54 2009
New Revision: 176360
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=176360
Log:
Might want to update the buffer pointer after a realloc (or we crash)
(closes issue #14485)
Reported by: davevg
Modified:
trunk/main/strings.c
Modified: trunk/main/strings.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/strings.c?view=diff&rev=176360&r1=176359&r2=176360
==============================================================================
--- trunk/main/strings.c (original)
+++ trunk/main/strings.c Mon Feb 16 17:48:54 2009
@@ -131,6 +131,7 @@
(*buf)->__AST_STR_USED++;
if (dynamic && (!maxlen || (escapecommas && !(maxlen - 1)))) {
+ char *oldbase = (*buf)->__AST_STR_STR;
size_t old = (*buf)->__AST_STR_LEN;
if (ast_str_make_space(buf, (*buf)->__AST_STR_LEN * 2)) {
/* If the buffer can't be extended, end it. */
@@ -138,6 +139,11 @@
}
/* What we extended the buffer by */
maxlen = old;
+
+ /* Update ptr, if necessary */
+ if ((*buf)->__AST_STR_STR != oldbase) {
+ ptr = ptr - oldbase + (*buf)->__AST_STR_STR;
+ }
}
}
if (__builtin_expect(!(maxsrc && maxlen), 0)) {
More information about the svn-commits
mailing list