summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-03-12 08:37:18 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-03-12 08:37:18 +0100
commit2f0c512feeab405a9475036b039d8bade9d238fd (patch)
tree412dda62b02973380d5e43d45d55702b12708ccf
parent57c70767930c0f0cbf93c56c28442cf34eb6af07 (diff)
downloadcurl-bagder/coverity-memdebug.tar.gz
memdebug: log pointer before freeing its databagder/coverity-memdebug
Coverity warned for two potention "Use after free" cases. Both are false positives because the memory wasn't used, it was only the actual pointer value that was logged. The fix still changes the order of execution to avoid the warnings. Coverity CID 1443033 and 1443034
-rw-r--r--lib/curl_addrinfo.c4
-rw-r--r--lib/memdebug.c6
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c
index 961311fa3..16c4779c1 100644
--- a/lib/curl_addrinfo.c
+++ b/lib/curl_addrinfo.c
@@ -550,13 +550,13 @@ void
curl_dbg_freeaddrinfo(struct addrinfo *freethis,
int line, const char *source)
{
+ curl_dbg_log("ADDR %s:%d freeaddrinfo(%p)\n",
+ source, line, (void *)freethis);
#ifdef USE_LWIPSOCK
lwip_freeaddrinfo(freethis);
#else
(freeaddrinfo)(freethis);
#endif
- curl_dbg_log("ADDR %s:%d freeaddrinfo(%p)\n",
- source, line, (void *)freethis);
}
#endif /* defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) */
diff --git a/lib/memdebug.c b/lib/memdebug.c
index 5fcddc4e1..e3ac8edf7 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -463,11 +463,11 @@ int curl_dbg_fclose(FILE *file, int line, const char *source)
DEBUGASSERT(file != NULL);
- res = fclose(file);
-
if(source)
curl_dbg_log("FILE %s:%d fclose(%p)\n",
- source, line, (void *)file);
+ source, line, (void *)file);
+
+ res = fclose(file);
return res;
}