Fix parsing of '' strings. found by AFL

This commit is contained in:
Jason Turner 2016-03-26 17:34:36 -06:00
parent a45c76721f
commit 2f2f789f48
2 changed files with 8 additions and 1 deletions

View File

@ -1196,7 +1196,7 @@ namespace chaiscript
std::string match; std::string match;
{ {
// scope for cparser destrutor // scope for cparser destructor
Char_Parser<std::string> cparser(match, false); Char_Parser<std::string> cparser(match, false);
for (auto s = start + 1, end = m_position - 1; s != end; ++s) { for (auto s = start + 1, end = m_position - 1; s != end; ++s) {
@ -1204,6 +1204,10 @@ namespace chaiscript
} }
} }
if (match.size() != 1) {
throw exception::eval_error("Single-quoted strings must be 1 character long", File_Position(m_position.line, m_position.col), *m_filename);
}
m_match_stack.push_back(make_node<eval::Single_Quoted_String_AST_Node>(match, start.line, start.col)); m_match_stack.push_back(make_node<eval::Single_Quoted_String_AST_Node>(match, start.line, start.col));
return true; return true;
} }

View File

@ -371,6 +371,9 @@ int main(int argc, char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
} }
catch (const chaiscript::exception::load_module_error &e) {
std::cout << "Unhandled module load error\n" << e.what() << '\n';
}
// catch (std::exception &e) { // catch (std::exception &e) {
// std::cout << e.what() << '\n'; // std::cout << e.what() << '\n';