Fixed FP, nullpointer for memchr.

This commit is contained in:
orbitcowboy 2014-04-08 18:39:50 +02:00
parent 89dc652af9
commit dd61c5db47
2 changed files with 20 additions and 1 deletions

View File

@ -154,7 +154,7 @@
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1"><not-null/><not-uninit/></arg>
<arg nr="2"><not-null/><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="2"><not-uninit/><not-bool/><valid>0-</valid></arg>
<arg nr="3"><not-bool/><valid>0-</valid></arg>
</function>
<function name="memcmp">

View File

@ -83,6 +83,7 @@ private:
TEST_CASE(functioncallDefaultArguments);
TEST_CASE(nullpointer_internal_error); // #5080
TEST_CASE(nullpointerFputc); // #5645 FP: Null pointer dereference in fputc argument
TEST_CASE(nullpointerMemchr);
// Test that std.cfg is configured correctly
TEST_CASE(stdcfg);
@ -2554,6 +2555,24 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: nullstring\n", errout.str());
}
void nullpointerMemchr() {
check("void f (char *p, char *s) {\n"
" p = memchr (s, 'p', strlen(s));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f (char *p, char *s) {\n"
" p = memchr (s, 0, strlen(s));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void f (char *p) {\n"
" char *s = 0;\n"
" p = memchr (s, 0, strlen(s));\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: s\n", errout.str());
}
};
REGISTER_TEST(TestNullPointer)