Bug 10201

Summary: buildroot-2017.08-rc1/toolchain/toolchain-wrapper.c:192]: (error) Memory leak:
Product: buildroot Reporter: David Binderman <dcb314>
Component: OtherAssignee: unassigned
Status: RESOLVED WONTFIX    
Severity: minor CC: buildroot
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description David Binderman 2017-08-09 20:18:41 UTC
Source code is

        basename = progpath;
        absbasedir = malloc(PATH_MAX + 1);
        ret = readlink("/proc/self/exe", absbasedir, PATH_MAX);
        if (ret < 0) {
            perror(__FILE__ ": readlink");
            return 2;
        }

Probably not worth much, but a call to free would shut up
the static analyser.
Comment 1 Arnout Vandecappelle 2017-08-11 14:15:45 UTC
Your static analyser is weird, because there are a few other things which aren't freed either: relbasedir, absbasedir in different code paths.

However, we do this by choice. Freeing things before exiting is useless, since the OS will implicitly free everything when the program exits. That's why e.g. valgrind doesn't report these as real memory leaks (because they are still reachable).

So no, this is not a memory leak.

For consistency, the free(args) at the end should be removed, but that's a different issue.