fdread.c doread
Free the memory allocated to trackbuf before exiting
Details
Details
Use clang's static analyzer, scan-build, to find the problem and then to verify the problem is resolved
Diff Detail
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
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.