Fixed FP for nullpointer dereference when using putchar.
This commit is contained in:
parent
9b1d058410
commit
baf8d09a0d
|
@ -212,7 +212,7 @@
|
|||
<function name="putchar">
|
||||
<noreturn>false</noreturn>
|
||||
<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>
|
||||
</function>
|
||||
<function name="puts">
|
||||
<noreturn>false</noreturn>
|
||||
|
|
|
@ -84,6 +84,7 @@ private:
|
|||
TEST_CASE(nullpointer_internal_error); // #5080
|
||||
TEST_CASE(nullpointerFputc); // #5645 FP: Null pointer dereference in fputc argument
|
||||
TEST_CASE(nullpointerMemchr);
|
||||
TEST_CASE(nullpointerPutchar);
|
||||
|
||||
// Test that std.cfg is configured correctly
|
||||
TEST_CASE(stdcfg);
|
||||
|
@ -2573,6 +2574,23 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: s\n", errout.str());
|
||||
}
|
||||
|
||||
void nullpointerPutchar() {
|
||||
check("void f (char *c) {\n"
|
||||
" putchar(c);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f () {\n"
|
||||
" putchar(0);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f () {\n"
|
||||
" putchar(*0);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Null pointer dereference\n", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestNullPointer)
|
||||
|
|
Loading…
Reference in New Issue