diff options
author | Miroslav Franc <mfranc@gmx.com> | 2016-07-13 18:43:18 +0200 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2016-07-14 02:52:56 -0400 |
commit | bf430ecdef3d7c49cf01a57e3289ff7aaa1e0278 (patch) | |
tree | 23c527882f799236ae2a01cc19e73952dcd7727a /lib/file.c | |
parent | bcc8f485e5e364deb6b5ad8502635b4358aaa277 (diff) | |
download | curl-bf430ecdef3d7c49cf01a57e3289ff7aaa1e0278.tar.gz |
library: Fix memory leaks found during static analysis
Closes https://github.com/curl/curl/pull/913
Diffstat (limited to 'lib/file.c')
-rw-r--r-- | lib/file.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/file.c b/lib/file.c index be7660cfb..b534ec18d 100644 --- a/lib/file.c +++ b/lib/file.c @@ -227,15 +227,19 @@ static CURLcode file_connect(struct connectdata *conn, bool *done) for(i=0; i < real_path_len; ++i) if(actual_path[i] == '/') actual_path[i] = '\\'; - else if(!actual_path[i]) /* binary zero */ + else if(!actual_path[i]) { /* binary zero */ + Curl_safefree(real_path); return CURLE_URL_MALFORMAT; + } fd = open_readonly(actual_path, O_RDONLY|O_BINARY); file->path = actual_path; #else - if(memchr(real_path, 0, real_path_len)) + if(memchr(real_path, 0, real_path_len)) { /* binary zeroes indicate foul play */ + Curl_safefree(real_path); return CURLE_URL_MALFORMAT; + } fd = open_readonly(real_path, O_RDONLY); file->path = real_path; |