Fix FP: tmpnam() expects a valid pointer, an uninitialized array (of conforming size) is fine

This commit is contained in:
Alexander Mai 2014-09-27 20:29:54 +02:00
parent e1218cf846
commit b0c34390cd
2 changed files with 12 additions and 1 deletions

View File

@ -752,7 +752,7 @@
</arg> <arg nr="3"><valid>0,2:36</valid></arg>
</function>
<function name="time"> <noreturn>false</noreturn> <leak-ignore/> </function>
<function name="tmpnam"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><not-uninit/></arg></function>
<function name="tmpnam"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"></arg></function>
<function name="tmpfile"> <noreturn>false</noreturn> </function>
<function name="tolower"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>
<function name="toupper"> <noreturn>false</noreturn> <leak-ignore/> <arg nr="1"><valid>0:255</valid></arg> </function>

View File

@ -3800,6 +3800,17 @@ private:
" mbstowcs (wbuf, str, 3);\n"
"}");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo() {\n"
" char buf[10];\n"
" tmpnam(buf);\n"
"}");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo() {\n"
" char *ptr;\n"
" tmpnam(ptr);\n"
"}");
TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: ptr\n", "", errout.str());
}
void checkDeadPointer(const char code[]) {