4 ms·
I personally would want code like this flagged by static analysis. I would fix the code by not calling free in the second 'if' body if needfree was already fals
by jjnoakes 7y ago
I personally would want code like this flagged by static analysis. I would fix the code by not calling free in the second 'if' body if needfree was already false (just like the call at the end of the function is guarded).
- nullc 7y agoYou might want it flagged-- I would--, but it would still be a false positive if it did so (assuming the constants didn't result in a double-free). :)
- kccqzy 7y agoI think the argument is that static analyzers don't have to work on completely unchanged code, but rather rely on humans to structure the code in a way to avoid issues. Many years ago people regularly wrote things like "if (retval = f())" but after compilers started to complain about it people changed to write "if ((retval = f()))" instead, if they want an assignment and truthfulness testing at the same time.
- deleted 7y ago[deleted]