mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-07 01:06:54 +08:00
Fix unhandled exception found via libfuzzer
This commit is contained in:
parent
ea03a5462f
commit
cfb2e663d3
@ -1051,6 +1051,7 @@ namespace chaiscript
|
|||||||
Char_Parser &operator=(const Char_Parser &) = delete;
|
Char_Parser &operator=(const Char_Parser &) = delete;
|
||||||
|
|
||||||
~Char_Parser(){
|
~Char_Parser(){
|
||||||
|
try {
|
||||||
if (is_octal) {
|
if (is_octal) {
|
||||||
process_octal();
|
process_octal();
|
||||||
}
|
}
|
||||||
@ -1062,12 +1063,18 @@ namespace chaiscript
|
|||||||
if (is_unicode) {
|
if (is_unicode) {
|
||||||
process_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()
|
void process_hex()
|
||||||
{
|
{
|
||||||
|
if (!hex_matches.empty()) {
|
||||||
auto val = stoll(hex_matches, nullptr, 16);
|
auto val = stoll(hex_matches, nullptr, 16);
|
||||||
match.push_back(char_type(val));
|
match.push_back(char_type(val));
|
||||||
|
}
|
||||||
hex_matches.clear();
|
hex_matches.clear();
|
||||||
is_escaped = false;
|
is_escaped = false;
|
||||||
is_hex = false;
|
is_hex = false;
|
||||||
@ -1076,8 +1083,10 @@ namespace chaiscript
|
|||||||
|
|
||||||
void process_octal()
|
void process_octal()
|
||||||
{
|
{
|
||||||
|
if (!octal_matches.empty()) {
|
||||||
auto val = stoll(octal_matches, nullptr, 8);
|
auto val = stoll(octal_matches, nullptr, 8);
|
||||||
match.push_back(char_type(val));
|
match.push_back(char_type(val));
|
||||||
|
}
|
||||||
octal_matches.clear();
|
octal_matches.clear();
|
||||||
is_escaped = false;
|
is_escaped = false;
|
||||||
is_octal = false;
|
is_octal = false;
|
||||||
@ -1086,9 +1095,11 @@ namespace chaiscript
|
|||||||
|
|
||||||
void process_unicode()
|
void process_unicode()
|
||||||
{
|
{
|
||||||
|
if (!hex_matches.empty()) {
|
||||||
auto val = stoll(hex_matches, nullptr, 16);
|
auto val = stoll(hex_matches, nullptr, 16);
|
||||||
hex_matches.clear();
|
hex_matches.clear();
|
||||||
match += detail::Char_Parser_Helper<string_type>::str_from_ll(val);
|
match += detail::Char_Parser_Helper<string_type>::str_from_ll(val);
|
||||||
|
}
|
||||||
is_escaped = false;
|
is_escaped = false;
|
||||||
is_unicode = false;
|
is_unicode = false;
|
||||||
}
|
}
|
||||||
@ -1254,6 +1265,7 @@ namespace chaiscript
|
|||||||
cparser.saw_interpolation_marker = false;
|
cparser.saw_interpolation_marker = false;
|
||||||
} else {
|
} else {
|
||||||
cparser.parse(*s, start.line, start.col, *m_filename);
|
cparser.parse(*s, start.line, start.col, *m_filename);
|
||||||
|
|
||||||
++s;
|
++s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user