diff --git a/src/jansson-2.6/src/strbuffer.c b/src/jansson-2.6/src/strbuffer.c index c8abf46e..b93231cd 100644 --- a/src/jansson-2.6/src/strbuffer.c +++ b/src/jansson-2.6/src/strbuffer.c @@ -11,6 +11,7 @@ #include #include +#include #include "jansson_private.h" #include "strbuffer.h" @@ -74,6 +75,7 @@ int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) { if(size >= strbuff->size - strbuff->length) { + int backoff = 1; size_t new_size; char *new_value; @@ -86,9 +88,13 @@ int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) new_size = max(strbuff->size * STRBUFFER_FACTOR, strbuff->length + size + 1); - new_value = realloc(strbuff->value, new_size); - if(!new_value) - return -1; + while (42) { + new_value = realloc(strbuff->value, new_size); + if (new_value) + break; + usleep(backoff * 1000); + backoff <<= 1; + } strbuff->value = new_value; strbuff->size = new_size;