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)
Sat, Apr 20, 2:35 PM
Unknown Object (File)
Sat, Apr 20, 1:33 PM
Unknown Object (File)
Mar 17 2024, 4:00 PM
Unknown Object (File)
Mar 17 2024, 3:32 PM
Unknown Object (File)
Mar 13 2024, 5:10 PM
Unknown Object (File)
Dec 20 2023, 1:30 AM
Unknown Object (File)
Oct 25 2023, 9:58 AM
Unknown Object (File)
Jul 23 2023, 6:17 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.