Decode: ensure signed numbers don't start with an underscore (#698)

This commit is contained in:
Cameron Moore
2021-12-04 15:56:48 -06:00
committed by GitHub
parent f53bc740c1
commit 6cd86876b8
2 changed files with 16 additions and 3 deletions
+7 -2
View File
@@ -386,8 +386,13 @@ func parseIntDec(b []byte) (int64, error) {
}
func checkAndRemoveUnderscoresIntegers(b []byte) ([]byte, error) {
if b[0] == '_' {
return nil, newDecodeError(b[0:1], "number cannot start with underscore")
start := 0
if b[start] == '+' || b[start] == '-' {
start++
}
if b[start] == '_' {
return nil, newDecodeError(b[start:start+1], "number cannot start with underscore")
}
if b[len(b)-1] == '_' {