1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

url: fixed a memory leak on OOM while setting CURLOPT_BUFFERSIZE

This commit is contained in:
Dan Fandrich 2017-04-29 18:52:51 +02:00
parent 584142892f
commit 12e7a8c3d6

View File

@ -2293,12 +2293,13 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
/* Resize only if larger than default buffer size. */ /* Resize only if larger than default buffer size. */
if(data->set.buffer_size > BUFSIZE) { if(data->set.buffer_size > BUFSIZE) {
data->state.buffer = realloc(data->state.buffer, char *newbuff = realloc(data->state.buffer, data->set.buffer_size + 1);
data->set.buffer_size + 1); if(!newbuff) {
if(!data->state.buffer) {
DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n")); DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n"));
result = CURLE_OUT_OF_MEMORY; result = CURLE_OUT_OF_MEMORY;
} }
else
data->state.buffer = newbuff;
} }
break; break;