1
0
mirror of https://github.com/json-iterator/go.git synced 2025-07-03 23:30:41 +02:00

#135 fix double negative

This commit is contained in:
Tao Wen
2017-07-18 11:05:39 +08:00
parent f6da8e62c3
commit c966eaa031
2 changed files with 29 additions and 0 deletions

View File

@ -159,6 +159,14 @@ func (iter *Iterator) readFloat32SlowPath() (ret float32) {
if iter.Error != nil && iter.Error != io.EOF {
return
}
if len(str) == 0 {
iter.ReportError("readFloat32SlowPath", "empty number")
return
}
if str[0] == '-' {
iter.ReportError("readFloat32SlowPath", "-- is not valid")
return
}
val, err := strconv.ParseFloat(str, 32)
if err != nil {
iter.Error = err
@ -233,6 +241,14 @@ func (iter *Iterator) readFloat64SlowPath() (ret float64) {
if iter.Error != nil && iter.Error != io.EOF {
return
}
if len(str) == 0 {
iter.ReportError("readFloat64SlowPath", "empty number")
return
}
if str[0] == '-' {
iter.ReportError("readFloat64SlowPath", "-- is not valid")
return
}
val, err := strconv.ParseFloat(str, 64)
if err != nil {
iter.Error = err