Page MenuHomeFreeBSD

Fix a memory leak in fdread
ClosedPublic

Authored by trix_juniper.net on Mar 2 2017, 4:53 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 25, 1:02 PM
Unknown Object (File)
Sat, Dec 21, 3:51 PM
Unknown Object (File)
Sun, Dec 15, 7:31 PM
Unknown Object (File)
Oct 3 2024, 10:01 AM
Unknown Object (File)
Oct 2 2024, 6:17 AM
Unknown Object (File)
Oct 1 2024, 7:18 AM
Unknown Object (File)
Sep 30 2024, 2:20 AM
Unknown Object (File)
Sep 29 2024, 10:30 PM
Subscribers

Details

Summary

fdread.c doread
Free the memory allocated to trackbuf before exiting

Test Plan

Use clang's static analyzer, scan-build, to find the problem and then to verify the problem is resolved

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

trix_juniper.net retitled this revision from to Fix a memory leak in fdread.
trix_juniper.net updated this object.
trix_juniper.net edited the test plan for this revision. (Show Details)
trix_juniper.net added reviewers: stevek, araujo.
trix_juniper.net set the repository for this revision to rS FreeBSD src repository - subversion.

Do you still have the log of analyzer before and after this patch?

I will have to reproduce these, I will send it out asap.

This is the before, the line number is a bit screwed up because i commented out my change.
The after has memory leak removed.

usr.sbin/fdread/fdread.c:134:2: warning: Value stored to 'argv' is never read

argv += optind;
^       ~~~~~~

usr.sbin/fdread/fdread.c:243:14: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage

fdopts |= FDOPT_NOERROR;
~~~~~~ ^

usr.sbin/fdread/fdread.c:291:7: warning: Potential leak of memory pointed to by 'trackbuf'

if (!quiet) {
     ^~~~~

3 warnings generated.
scan-build: 3 bugs found.

Looks good to me! Do you want me commit it or you have src bit?

Best,

This revision is now accepted and ready to land.Mar 12 2017, 5:22 AM

Yes, please commit. I do not have commit perms.
Thank you,
Tom

This revision was automatically updated to reflect the committed changes.