Bug 674 - Do not free ponters given by getenv()
Do not free ponters given by getenv()
Status: RESOLVED FIXED
Product: unbound
Classification: Unclassified
Component: server
unspecified
All Windows
: P5 major
Assigned To: unbound team
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-06-02 00:56 CEST by Thomas Winget
Modified: 2015-06-02 09:34 CEST (History)
3 users (show)

See Also:


Attachments
patch, modify paths as needed (577 bytes, text/plain)
2015-06-02 00:56 CEST, Thomas Winget
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Winget 2015-06-02 00:56:10 CEST
Created attachment 284 [details]
patch, modify paths as needed

In the file unbound/libunbound/libunbound.c, if Windows is detected as the OS and no hosts file is specified, libunbound uses getenv() to determine the system-wide hosts file.  It should not be calling free() on the pointer returned by getenv(), see here: https://stackoverflow.com/questions/4237812/should-i-free-delete-char-returned-by-getenv

Simply removing the call to free() should be sufficient to address the issue.
Comment 1 Wouter Wijngaards 2015-06-02 09:34:28 CEST
Hi Thomas,

Thank you for the fixup.  Committed.

Best regards,
   Wouter