#7023 segmentation fault (invalid code) in astIsIntegral. Avoid crash, unfortunately there is no syntax error yet detected.
This commit is contained in:
parent
e99b4319c9
commit
88b3d90505
|
@ -47,7 +47,7 @@ bool astIsIntegral(const Token *tok, bool unknown)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Function call
|
// Function call
|
||||||
if (tok->previous()->function()) {
|
if (tok->previous() && tok->previous()->function()) {
|
||||||
if (Token::Match(tok->previous()->function()->retDef, "float|double"))
|
if (Token::Match(tok->previous()->function()->retDef, "float|double"))
|
||||||
return false;
|
return false;
|
||||||
else if (Token::Match(tok->previous()->function()->retDef, "bool|char|short|int|long"))
|
else if (Token::Match(tok->previous()->function()->retDef, "bool|char|short|int|long"))
|
||||||
|
|
|
@ -1075,7 +1075,7 @@ public:
|
||||||
ret = "float";
|
ret = "float";
|
||||||
else if (type == DOUBLE)
|
else if (type == DOUBLE)
|
||||||
ret = "double";
|
ret = "double";
|
||||||
for (int p = 0; p < pointer; p++)
|
for (unsigned int p = 0; p < pointer; p++)
|
||||||
ret += "*";
|
ret += "*";
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,6 +170,7 @@ private:
|
||||||
TEST_CASE(garbageCode128); // #7018
|
TEST_CASE(garbageCode128); // #7018
|
||||||
TEST_CASE(garbageCode129); // #7020
|
TEST_CASE(garbageCode129); // #7020
|
||||||
TEST_CASE(garbageCode130); // #7021
|
TEST_CASE(garbageCode130); // #7021
|
||||||
|
TEST_CASE(garbageCode131); // #7023
|
||||||
|
|
||||||
TEST_CASE(garbageValueFlow);
|
TEST_CASE(garbageValueFlow);
|
||||||
TEST_CASE(garbageSymbolDatabase);
|
TEST_CASE(garbageSymbolDatabase);
|
||||||
|
@ -983,6 +984,12 @@ private:
|
||||||
InternalError);
|
InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void garbageCode131() {
|
||||||
|
checkCode("( void ) { ( ) } ( ) / { ( ) }");
|
||||||
|
// actually the invalid code should trigger an syntax error...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void garbageValueFlow() {
|
void garbageValueFlow() {
|
||||||
// #6089
|
// #6089
|
||||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||||
|
|
Loading…
Reference in New Issue