Skip to content
Snippets Groups Projects
Commit 5b220b3e authored by Tilghman Lesher's avatar Tilghman Lesher
Browse files

Handle negative length and eliminate a condition that is always true.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@177287 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 6c2a537c
Branches
Tags
No related merge requests found
......@@ -114,8 +114,10 @@ char *__ast_str_helper2(struct ast_str **buf, size_t maxlen, const char *src, si
int dynamic = 0;
char *ptr = append ? &((*buf)->__AST_STR_STR[(*buf)->__AST_STR_USED]) : (*buf)->__AST_STR_STR;
if (!maxlen) {
dynamic = 1;
if (maxlen < 1) {
if (maxlen == 0) {
dynamic = 1;
}
maxlen = (*buf)->__AST_STR_LEN;
}
......@@ -140,10 +142,7 @@ 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;
}
ptr += (*buf)->__AST_STR_STR - oldbase;
}
}
if (__builtin_expect(!(maxsrc && maxlen), 0)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment