Fix a memory leak in libiberty

Authored by on Feb 20 2017, 5:06 PM.



The function make_relative_prefix_1 does not properly free locally allocated memory when it returns early.

Free the memory associated with the variables full_programe, bin_dirs, prog_dirs, and prefix_dirs when the
function returns early.

Test Plan

Run clang's static analyzer, scan-build, before to reproduce the problem; run scan-build after to show problem is resolved.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable. retitled this revision from to Fix a memory leak in libiberty.Feb 20 2017, 5:06 PM updated this object. edited the test plan for this revision. (Show Details) set the repository for this revision to rS FreeBSD src repository.
jhibbits accepted this revision.May 30 2017, 8:32 PM
This revision is now accepted and ready to land.May 30 2017, 8:32 PM

Now if someone could commit it..

stevek added inline comments.May 31 2017, 9:26 PM
302 ↗(On Diff #25435)

These if statements should really use the style of the file.

if (prog_dirs == NULL)
    free (full_progname);


Note the opening/closing braces on their own lines 2 space indented, with the rest of the block an additional 2 space indented.

emaste added a comment.Dec 5 2017, 8:31 PM

@stevek will you commit (with style fix)?

stevek added a comment.Dec 6 2017, 8:50 PM

@stevek will you commit (with style fix)?

Sure, I can do that.

This revision was automatically updated to reflect the committed changes.