Constructor parameter type need not be a number
This commit is contained in:
parent
9846ff10b2
commit
d735918a8a
|
@ -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