Merge pull request #576 from Dmitry-Me/anyParameterType
Constructor parameter type need not be a number
This commit is contained in:
commit
04a3196a32
|
@ -1064,7 +1064,7 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
|
|||
if (size < 0) {
|
||||
negativeMemoryAllocationSizeError(tok->next()->next());
|
||||
}
|
||||
} else if (Token::Match(tok, "[*;{}] %var% = new %type% ( %num% )")) {
|
||||
} else if (Token::Match(tok, "[*;{}] %var% = new %type% ( %num%|%name% )")) {
|
||||
size = 1;
|
||||
type = tok->strAt(4);
|
||||
var = tok->next()->variable();
|
||||
|
|
|
@ -3242,6 +3242,12 @@ private:
|
|||
"}", settings);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Buffer is accessed out of bounds.\n", errout.str());
|
||||
|
||||
check("void f(char value) {\n"
|
||||
" char *a = new char(value);\n"
|
||||
" mysprintf(a, \"a\");\n"
|
||||
"}", settings);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Buffer is accessed out of bounds.\n", errout.str());
|
||||
|
||||
// This is out of bounds if 'sizeof(ABC)' is 1 (No padding)
|
||||
check("struct Foo { char a[1]; };\n"
|
||||
"void f() {\n"
|
||||
|
|
Loading…
Reference in New Issue