Fixed FP, nullpointer for memchr.
This commit is contained in:
parent
89dc652af9
commit
dd61c5db47
|
@ -154,7 +154,7 @@
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
<arg nr="1"><not-null/><not-uninit/></arg>
|
<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>
|
<arg nr="3"><not-bool/><valid>0-</valid></arg>
|
||||||
</function>
|
</function>
|
||||||
<function name="memcmp">
|
<function name="memcmp">
|
||||||
|
|
|
@ -83,6 +83,7 @@ private:
|
||||||
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_CASE(nullpointerFputc); // #5645 FP: Null pointer dereference in fputc argument
|
||||||
|
TEST_CASE(nullpointerMemchr);
|
||||||
|
|
||||||
// Test that std.cfg is configured correctly
|
// Test that std.cfg is configured correctly
|
||||||
TEST_CASE(stdcfg);
|
TEST_CASE(stdcfg);
|
||||||
|
@ -2554,6 +2555,24 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Possible null pointer dereference: nullstring\n", errout.str());
|
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)
|
REGISTER_TEST(TestNullPointer)
|
||||||
|
|
Loading…
Reference in New Issue