Decode: fix panic when parsing '0' as a float (#887)

Fixes #886
This commit is contained in:
Haiyang Wang
2023-08-23 00:07:39 +08:00
committed by GitHub
parent f7d9b9ba53
commit bb026cae89
2 changed files with 6 additions and 1 deletions
+1 -1
View File
@@ -318,7 +318,7 @@ func parseFloat(b []byte) (float64, error) {
if cleaned[0] == '+' || cleaned[0] == '-' {
start = 1
}
if cleaned[start] == '0' && isDigit(cleaned[start+1]) {
if cleaned[start] == '0' && len(cleaned) > start+1 && isDigit(cleaned[start+1]) {
return 0, unstable.NewParserError(b, "float integer part cannot have leading zeroes")
}