Fix unhandled exception found via libfuzzer

This commit is contained in:
Jason Turner 2017-07-19 10:09:44 -06:00
parent ea03a5462f
commit cfb2e663d3

View File

@ -1051,6 +1051,7 @@ namespace chaiscript
Char_Parser &operator=(const Char_Parser &) = delete;
~Char_Parser(){
try {
if (is_octal) {
process_octal();
}
@ -1062,12 +1063,18 @@ namespace chaiscript
if (is_unicode) {
process_unicode();
}
} catch (const std::invalid_argument &) {
// escape sequence was invalid somehow, we'll pick this
// up in the next part of parsing
}
}
void process_hex()
{
if (!hex_matches.empty()) {
auto val = stoll(hex_matches, nullptr, 16);
match.push_back(char_type(val));
}
hex_matches.clear();
is_escaped = false;
is_hex = false;
@ -1076,8 +1083,10 @@ namespace chaiscript
void process_octal()
{
if (!octal_matches.empty()) {
auto val = stoll(octal_matches, nullptr, 8);
match.push_back(char_type(val));
}
octal_matches.clear();
is_escaped = false;
is_octal = false;
@ -1086,9 +1095,11 @@ namespace chaiscript
void process_unicode()
{
if (!hex_matches.empty()) {
auto val = stoll(hex_matches, nullptr, 16);
hex_matches.clear();
match += detail::Char_Parser_Helper<string_type>::str_from_ll(val);
}
is_escaped = false;
is_unicode = false;
}
@ -1254,6 +1265,7 @@ namespace chaiscript
cparser.saw_interpolation_marker = false;
} else {
cparser.parse(*s, start.line, start.col, *m_filename);
++s;
}
}