fix panic when parsing invalid decimal, close #3796

This commit is contained in:
Dennis Zhuang committed 2022-06-19 22:34:34 +08:00
1 parent 531f678706
commit 623a78dbf9
2 files changed
+10 -1

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
try:
eval("0.E")
except SyntaxError:
pass
else:
assert False
+4 -1
View File
@@ -300,7 +300,10 @@ where
value_text.push_str(&self.radix_run(10));
}
let value = f64::from_str(&value_text).unwrap();
let value = f64::from_str(&value_text).map_err(|_| LexicalError {
error: LexicalErrorType::OtherError("Invalid decimal literal".to_owned()),
location: self.get_pos(),
})?;
// Parse trailing 'j':
if self.chr0 == Some('j') || self.chr0 == Some('J') {
self.next_char();