1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-21 23:07:33 +02:00

fix read int ranges

This commit is contained in:
Tao Wen
2017-01-15 23:17:17 +08:00
parent 399ee3faaa
commit 54a69f1da2
4 changed files with 120 additions and 169 deletions

View File

@ -331,16 +331,8 @@ func (iter *Iterator) readU4() (ret rune) {
return
}
if c >= '0' && c <= '9' {
if ret >= cutoffUint32 {
iter.reportError("readU4", "overflow")
return
}
ret = ret*16 + rune(c-'0')
} else if c >= 'a' && c <= 'f' {
if ret >= cutoffUint32 {
iter.reportError("readU4", "overflow")
return
}
ret = ret*16 + rune(c-'a'+10)
} else {
iter.reportError("readU4", "expects 0~9 or a~f")