fixed bug where unterminated #define would crash the game
This commit is contained in:
parent
15eb7bfb8e
commit
9a23626d6e
1 changed files with 9 additions and 5 deletions
|
@ -235,17 +235,21 @@ void internal_preprocess_data(const std::string& data,
|
|||
args.erase(args.begin());
|
||||
|
||||
std::stringstream value;
|
||||
for(i = end+1; i != data.end(); ++i) {
|
||||
static const std::string hash_enddef("#enddef");
|
||||
if(size_t(data.end() - i) > hash_enddef.size() &&
|
||||
std::equal(hash_enddef.begin(),hash_enddef.end(),i)) {
|
||||
i += hash_enddef.size();
|
||||
static const std::string hash_enddef("#enddef");
|
||||
for(i = end+1; i <= data.end() - hash_enddef.size(); ++i) {
|
||||
if(std::equal(hash_enddef.begin(),hash_enddef.end(),i)) {
|
||||
break;
|
||||
}
|
||||
|
||||
value << *i;
|
||||
}
|
||||
|
||||
if(i > data.end() - hash_enddef.size()) {
|
||||
throw config::error("pre-processing condition unterminated in '" + fname + "': '" + items + "'");
|
||||
}
|
||||
|
||||
i += hash_enddef.size();
|
||||
|
||||
defines_map.insert(std::pair<std::string,preproc_define>(
|
||||
symbol,preproc_define(value.str(),args)));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue