Fixed file descriptor leak

This commit is contained in:
Luca Deri 2018-03-28 08:17:33 +02:00
parent 945a9f9789
commit ef2638d00a
3 changed files with 36 additions and 21 deletions

View file

@ -1072,7 +1072,7 @@ bool Utils::postHTTPTextFile(char *username, char *password, char *url,
size_t file_len;
FILE *fd = fopen(path, "r");
if((fd== NULL) || (stat(path, &file_info) != 0))
if((fd == NULL) || (stat(path, &file_info) != 0))
return(false);
else
file_len = (size_t)file_info.st_size;
@ -1120,6 +1120,8 @@ bool Utils::postHTTPTextFile(char *username, char *password, char *url,
ntop->getTrace()->traceEvent(TRACE_INFO, "Posted JSON to %s", url);
readCurlStats(curl, stats, NULL);
}
fclose(fd);
/* always cleanup */
curl_slist_free_all(headers);