dect
/
asterisk
Archived
13
0
Fork 0

Might want to update the buffer pointer after a realloc (or we crash)

(closes issue #14485)
 Reported by: davevg


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@176360 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
tilghman 2009-02-16 23:48:54 +00:00
parent 046babfbe9
commit 27c4fd2856
1 changed files with 6 additions and 0 deletions

View File

@ -131,6 +131,7 @@ char *__ast_str_helper2(struct ast_str **buf, size_t maxlen, const char *src, si
(*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 @@ char *__ast_str_helper2(struct ast_str **buf, size_t maxlen, const char *src, si
}
/* 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)) {