-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertInteger: can not decode float as int for valid input from chunked reader #476
Comments
mrVanboy
added a commit
to kiwicom/jsoniter
that referenced
this issue
Jul 18, 2020
This commit fixes bug in Iterator.assertInteger method if the next conditions are met: - Iterator reads data from `io.Reader`, - expected value is `0` (zero) - `Iterator.tail == Iterator.head + 1` - `Iterator.tail < len(Iterator.buf)` - value in the buffer after `Iterator.tail` is presented from the previous read and has '.' character. Typical error which user cal see is: - assertInteger: can not decode float as int, error found in #X byte of ... Regression test added for checking the correct behaviour. Fixes json-iterator#476
mrVanboy
added a commit
to kiwicom/jsoniter
that referenced
this issue
Aug 5, 2020
This commit fixes bug in Iterator.assertInteger method if the next conditions are met: - Iterator reads data from `io.Reader`, - expected value is `0` (zero) - `Iterator.tail == Iterator.head + 1` - `Iterator.tail < len(Iterator.buf)` - value in the buffer after `Iterator.tail` is presented from the previous read and has '.' character. Typical error which user cal see is: - assertInteger: can not decode float as int, error found in #X byte of ... Regression test added for checking the correct behaviour. Fixes json-iterator#476
AllenX2018
pushed a commit
that referenced
this issue
Aug 6, 2020
…477) This commit fixes bug in Iterator.assertInteger method if the next conditions are met: - Iterator reads data from `io.Reader`, - expected value is `0` (zero) - `Iterator.tail == Iterator.head + 1` - `Iterator.tail < len(Iterator.buf)` - value in the buffer after `Iterator.tail` is presented from the previous read and has '.' character. Typical error which user cal see is: - assertInteger: can not decode float as int, error found in #X byte of ... Regression test added for checking the correct behaviour. Fixes #476
@AllenX2018 any chance this will get into the next tag? |
zhenzou
pushed a commit
to zhenzou/jsoniter
that referenced
this issue
Feb 2, 2022
…son-iterator#477) This commit fixes bug in Iterator.assertInteger method if the next conditions are met: - Iterator reads data from `io.Reader`, - expected value is `0` (zero) - `Iterator.tail == Iterator.head + 1` - `Iterator.tail < len(Iterator.buf)` - value in the buffer after `Iterator.tail` is presented from the previous read and has '.' character. Typical error which user cal see is: - assertInteger: can not decode float as int, error found in #X byte of ... Regression test added for checking the correct behaviour. Fixes json-iterator#476
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
we found a bug during unmarshaling large responses from HTTP.Request.Body. The next conditions should be met:
io.Reader
,0
(zero)Iterator.tail == Iterator.head + 1
Iterator.tail < len(Iterator.buf)
Iterator.tail
is presented from the previous read and has '.' character.Basically, let's assume that
Iterator
reads data from the reader which returns less data, than the size of the buffer. After a couple of reads, the buffer will have the content like:0.0, 0.0, 0
.The first item is from the latest read, other items are from the older readers, so have:
When the
Iterator.ReadInt
is called, it reads zero and checks if the value is an integer by callingassertInteger()
method, which currently looks like:The only issue is, that it checks for
iter.head < len(iter.buf)
instead ofiter.head < iter.tail
and the assertion is done against the dot.
from the previous read.The test for replicating this behavior will be provided in ongoing PR.
The text was updated successfully, but these errors were encountered: