diff --git a/cfg/std.cfg b/cfg/std.cfg
index 5a7755499..ccf3426bc 100644
--- a/cfg/std.cfg
+++ b/cfg/std.cfg
@@ -42,7 +42,7 @@
false
- 0-
+ 0-
diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp
index 3f121dafa..857250f07 100644
--- a/test/testnullpointer.cpp
+++ b/test/testnullpointer.cpp
@@ -82,6 +82,7 @@ private:
TEST_CASE(crash1);
TEST_CASE(functioncallDefaultArguments);
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_CASE(stdcfg);
@@ -2534,6 +2535,25 @@ private:
check("void f(char * p,char * q){ strtol (p,q,0);if(!p){}}");
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)