#5645 False positive Null pointer derefence about first argument to fputc()
This commit is contained in:
parent
d7e2e3bd5e
commit
9ae59290dd
|
@ -42,7 +42,7 @@
|
||||||
<function name="fputc">
|
<function name="fputc">
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1"><not-null/><not-uninit/><not-bool/><valid>0-</valid></arg>
|
<arg nr="1"><not-uninit/><not-bool/><valid>0-</valid></arg>
|
||||||
<arg nr="2"><not-null/><not-uninit/></arg>
|
<arg nr="2"><not-null/><not-uninit/></arg>
|
||||||
</function>
|
</function>
|
||||||
<function name="fputs">
|
<function name="fputs">
|
||||||
|
|
|
@ -82,6 +82,7 @@ private:
|
||||||
TEST_CASE(crash1);
|
TEST_CASE(crash1);
|
||||||
TEST_CASE(functioncallDefaultArguments);
|
TEST_CASE(functioncallDefaultArguments);
|
||||||
TEST_CASE(nullpointer_internal_error); // #5080
|
TEST_CASE(nullpointer_internal_error); // #5080
|
||||||
|
TEST_CASE(nullpointerFputc); // #5645 FP: Null pointer dereference in fputc argument
|
||||||
|
|
||||||
// Test that std.cfg is configured correctly
|
// Test that std.cfg is configured correctly
|
||||||
TEST_CASE(stdcfg);
|
TEST_CASE(stdcfg);
|
||||||
|
@ -2534,6 +2535,25 @@ private:
|
||||||
check("void f(char * p,char * q){ strtol (p,q,0);if(!p){}}");
|
check("void f(char * p,char * q){ strtol (p,q,0);if(!p){}}");
|
||||||
ASSERT_EQUALS(errp,errout.str());
|
ASSERT_EQUALS(errp,errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nullpointerFputc() {
|
||||||
|
check("int main () {\n"
|
||||||
|
"FILE *fp = fopen(\"file.txt\", \"w+\");\n"
|
||||||
|
"fputc(000, fp); \n"
|
||||||
|
"fclose(fp);\n"
|
||||||
|
"return 0 ;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("int main () {\n"
|
||||||
|
"FILE *fp = fopen(\"file.txt\", \"w+\");\n"
|
||||||
|
"char *nullstring=0;"
|
||||||
|
"fputc(*nullstring, fp); \n"
|
||||||
|
"fclose(fp);\n"
|
||||||
|
"return 0 ;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: nullstring\n", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestNullPointer)
|
REGISTER_TEST(TestNullPointer)
|
||||||
|
|
Loading…
Reference in New Issue