Fix false positive invalidFunctionArg for zero arguments to calloc. (#3238)

This commit is contained in:
keinflue 2021-05-01 10:39:01 +00:00 committed by GitHub
parent a32d6257d5
commit 6541f52e61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -945,7 +945,7 @@
<returnValue type="void *"/> <returnValue type="void *"/>
<arg nr="1" direction="in"> <arg nr="1" direction="in">
<not-uninit/> <not-uninit/>
<valid>1:</valid> <valid>0:</valid>
</arg> </arg>
<arg nr="2" direction="in"> <arg nr="2" direction="in">
<not-uninit/> <not-uninit/>

View File

@ -433,11 +433,10 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str()); ASSERT_EQUALS("[test.cpp:2]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str());
check("void boolArgZeroIsInvalidButOneIsValid(int param) {\n" check("int boolArgZeroIsInvalidButOneIsValid(int a, int param) {\n"
" void* buffer = calloc(param > 0, 10);\n" " return div(a, param > 0);\n"
" free(buffer);\n"
"}"); "}");
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid calloc() argument nr 1. The value is 0 or 1 (boolean) but the valid values are '1:'.\n", errout.str()); ASSERT_EQUALS("[test.cpp:2]: (error) Invalid div() argument nr 2. The value is 0 or 1 (boolean) but the valid values are ':-1,1:'.\n", errout.str());
check("void boolArgZeroIsValidButOneIsInvalid(int param) {\n" check("void boolArgZeroIsValidButOneIsInvalid(int param) {\n"
" strtol(a, b, param > 0);\n" " strtol(a, b, param > 0);\n"