Preprocessor: Fix crashes for invalid code

This commit is contained in:
Daniel Marjamäki 2016-07-20 20:39:03 +02:00
parent 804d4194bb
commit f1839ebfaf
1 changed files with 4 additions and 2 deletions

View File

@ -219,11 +219,13 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string>
configs_ifndef.push_back((tok->next->str == "ifndef") ? config : std::string()); configs_ifndef.push_back((tok->next->str == "ifndef") ? config : std::string());
ret.insert(cfg(configs_if)); ret.insert(cfg(configs_if));
} else if (tok->next->str == "elif") { } else if (tok->next->str == "elif") {
configs_if.pop_back(); if (!configs_if.empty())
configs_if.pop_back();
configs_if.push_back(readcondition(tok->next, defined)); configs_if.push_back(readcondition(tok->next, defined));
ret.insert(cfg(configs_if)); ret.insert(cfg(configs_if));
} else if (tok->next->str == "else") { } else if (tok->next->str == "else") {
configs_if.pop_back(); if (!configs_if.empty())
configs_if.pop_back();
configs_if.push_back(configs_ifndef.back()); configs_if.push_back(configs_ifndef.back());
ret.insert(cfg(configs_if)); ret.insert(cfg(configs_if));
} else if (tok->next->str == "endif" && tok->location.sameline(tok->next->location)) { } else if (tok->next->str == "endif" && tok->location.sameline(tok->next->location)) {