diff options
author | Daniel Stenberg <daniel@haxx.se> | 2018-01-18 12:10:58 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-01-18 12:10:58 +0100 |
commit | 9e4ad1e2af22f00eeca533b745b67956f57319cb (patch) | |
tree | ae9f69f922dd5a3dd0c6e45197cca9575f1fe931 | |
parent | ca9c93e3e19f971030ec1da70c9e318ce493bffd (diff) |
openssl: fix potential memory leak in SSLKEYLOGFILE logic
Coverity CID 1427646.
-rw-r--r-- | lib/vtls/openssl.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 135e3ac54..93faa6fa8 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -944,20 +944,23 @@ static int Curl_ossl_init(void) #endif #ifdef ENABLE_SSLKEYLOGFILE - keylog_file_name = curl_getenv("SSLKEYLOGFILE"); - if(keylog_file_name && !keylog_file_fp) { - keylog_file_fp = fopen(keylog_file_name, FOPEN_APPENDTEXT); - if(keylog_file_fp) { + if(!keylog_file_fp) { + keylog_file_name = curl_getenv("SSLKEYLOGFILE"); + if(keylog_file_name) { + keylog_file_fp = fopen(keylog_file_name, FOPEN_APPENDTEXT); + if(keylog_file_fp) { #ifdef WIN32 - if(setvbuf(keylog_file_fp, NULL, _IONBF, 0)) { + if(setvbuf(keylog_file_fp, NULL, _IONBF, 0)) #else - if(setvbuf(keylog_file_fp, NULL, _IOLBF, 4096)) { + if(setvbuf(keylog_file_fp, NULL, _IOLBF, 4096)) #endif - fclose(keylog_file_fp); - keylog_file_fp = NULL; + { + fclose(keylog_file_fp); + keylog_file_fp = NULL; + } } + Curl_safefree(keylog_file_name); } - Curl_safefree(keylog_file_name); } #endif |