Fixed #4456 (std::string::compare(char const*) crash)
This commit is contained in:
parent
ed803b302b
commit
70059c06de
|
@ -214,8 +214,10 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok)
|
|||
return 0;
|
||||
|
||||
// Function pointer or prototype..
|
||||
while (tok->str() == "(")
|
||||
while (tok && tok->str() == "(")
|
||||
tok = tok->link()->next();
|
||||
if (!tok)
|
||||
return 0;
|
||||
|
||||
// inner template
|
||||
if (tok->str() == "<") {
|
||||
|
|
|
@ -140,6 +140,7 @@ private:
|
|||
TEST_CASE(if_cond12);
|
||||
TEST_CASE(if_cond13);
|
||||
TEST_CASE(if_cond14);
|
||||
TEST_CASE(if_cond15); // #4456 - segfault
|
||||
|
||||
TEST_CASE(if_or_1);
|
||||
TEST_CASE(if_or_2);
|
||||
|
@ -1586,6 +1587,20 @@ private:
|
|||
ASSERT_EQUALS("\n123\n\n", preprocessor.getcode(filedata,"",""));
|
||||
}
|
||||
|
||||
void if_cond15() { // #4456 - segmentation fault
|
||||
const char filedata[] = "#if ((A >= B) && (C != D))\n"
|
||||
"#if (E < F(1))\n"
|
||||
"#endif\n"
|
||||
"#endif\n";
|
||||
|
||||
// Preprocess => actual result..
|
||||
std::istringstream istr(filedata);
|
||||
std::map<std::string, std::string> actual;
|
||||
Settings settings;
|
||||
Preprocessor preprocessor(&settings, this);
|
||||
preprocessor.preprocess(istr, actual, "4456.c"); // <- don't crash in Preprocessor::getcfgs -> Tokenize -> number of template parameters
|
||||
}
|
||||
|
||||
|
||||
|
||||
void if_or_1() {
|
||||
|
|
Loading…
Reference in New Issue