diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2017-04-29 18:52:51 +0200 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2017-04-29 18:52:51 +0200 |
commit | 12e7a8c3d609d6a6094a7db8fb8c0cc80d8f55f0 (patch) | |
tree | a3177f24b132360f0a919fca0c56d5216c6798aa | |
parent | 584142892f7d5fb3100f3c0ef8e479d472b8c3c7 (diff) | |
download | curl-12e7a8c3d609d6a6094a7db8fb8c0cc80d8f55f0.tar.gz |
url: fixed a memory leak on OOM while setting CURLOPT_BUFFERSIZE
-rw-r--r-- | lib/url.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -2293,12 +2293,13 @@ CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option, /* Resize only if larger than default buffer size. */ if(data->set.buffer_size > BUFSIZE) { - data->state.buffer = realloc(data->state.buffer, - data->set.buffer_size + 1); - if(!data->state.buffer) { + char *newbuff = realloc(data->state.buffer, data->set.buffer_size + 1); + if(!newbuff) { DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n")); result = CURLE_OUT_OF_MEMORY; } + else + data->state.buffer = newbuff; } break; |