Hi, I found a false negative regarding the rule resourceLeak.
Cppcheck reports resourceLeak for the first program, but it misses the second program, which leaks file resources through a loop and early-return paths.
In this program, a is never closed after a successful fopen. In addition, when c == 'X', the function returns before fclose(b), so b is also leaked on that path.
Actual result
Cppcheck reports no resourceLeak warning for the second program.
Expected result
Cppcheck should report resourceLeak for a, and it should also report a leak for b on the c == 'X' early-return path.
Hi, I found a false negative regarding the rule
resourceLeak.Cppcheck reports
resourceLeakfor the first program, but it misses the second program, which leaks file resources through a loop and early-return paths.First program
Cppcheck reports:
Second program
In this program,
ais never closed after a successfulfopen. In addition, whenc == 'X', the function returns beforefclose(b), sobis also leaked on that path.Actual result
Cppcheck reports no
resourceLeakwarning for the second program.Expected result
Cppcheck should report
resourceLeakfora, and it should also report a leak forbon thec == 'X'early-return path.Verification
The issue was reproduced with:
Version: 2.21.0
Looks like an instance of https://trac.cppcheck.net/ticket/2565