I've managed to isolate a couple of false positives that are issues in our codebase. It's not clear how I go about getting an account to create these directly so I thought that I would post here!
Summary: Unnecessary comparison of static strings.
Message: The compared strings, '"aBcDeF"' and '"ABCDEF"', are always unequal. Therefore the comparison is unnecessary and looks suspicious.
However, the aMixed string is mutable and (in our application code) the function called does modify it so the memcmp is absolutely necessary.
FP 2
void bar()
{
baz *p;
p = malloc(sizeof *p);
free(p);
p = malloc(sizeof *p);
free(p);
}
On the second free statement, I get:
Summary: Memory pointed to by 'p' is freed twice.
Message: Memory pointed to by 'p' is freed twice.
Note that this only appears to be a problem if the pointer is to a user-defined type.
HTH,
Steve.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've managed to isolate a couple of false positives that are issues in our codebase. It's not clear how I go about getting an account to create these directly so I thought that I would post here!
FP 1
On the memcmp line, I get:
Summary: Unnecessary comparison of static strings.
Message: The compared strings, '"aBcDeF"' and '"ABCDEF"', are always unequal. Therefore the comparison is unnecessary and looks suspicious.
However, the aMixed string is mutable and (in our application code) the function called does modify it so the memcmp is absolutely necessary.
FP 2
On the second free statement, I get:
Summary: Memory pointed to by 'p' is freed twice.
Message: Memory pointed to by 'p' is freed twice.
Note that this only appears to be a problem if the pointer is to a user-defined type.
HTH,
Steve.
Created tickets 8119 and 8120 for these FPs.
S.