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