Skip to content

Commit

Permalink
memdebug: log pointer before freeing its data
Browse files Browse the repository at this point in the history
Coverity warned for two potentional "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

Closes #3671
  • Loading branch information
bagder committed Mar 12, 2019
1 parent 7e68fed commit 401cb92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/curl_addrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */

Expand Down
6 changes: 3 additions & 3 deletions lib/memdebug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 401cb92

Please sign in to comment.