summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/dynbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/dynbuf.c')
-rw-r--r--libs/libcurl/src/dynbuf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/libcurl/src/dynbuf.c b/libs/libcurl/src/dynbuf.c
index 124377b367..fc376a4e4b 100644
--- a/libs/libcurl/src/dynbuf.c
+++ b/libs/libcurl/src/dynbuf.c
@@ -76,6 +76,7 @@ static CURLcode dyn_nappend(struct dynbuf *s,
DEBUGASSERT(s->toobig);
DEBUGASSERT(indx < s->toobig);
DEBUGASSERT(!s->leng || s->bufr);
+ DEBUGASSERT(a <= s->toobig);
if(fit > s->toobig) {
Curl_dyn_free(s);
@@ -84,7 +85,9 @@ static CURLcode dyn_nappend(struct dynbuf *s,
else if(!a) {
DEBUGASSERT(!indx);
/* first invoke */
- if(fit < MIN_FIRST_ALLOC)
+ if(MIN_FIRST_ALLOC > s->toobig)
+ a = s->toobig;
+ else if(fit < MIN_FIRST_ALLOC)
a = MIN_FIRST_ALLOC;
else
a = fit;
@@ -92,6 +95,9 @@ static CURLcode dyn_nappend(struct dynbuf *s,
else {
while(a < fit)
a *= 2;
+ if(a > s->toobig)
+ /* no point in allocating a larger buffer than this is allowed to use */
+ a = s->toobig;
}
if(a != s->allc) {