You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is skipping ibytes rather than skipping ivariable-length zig-zag encoded integers. For i within 1..=63, the encoding outputs a single byte so this happens to work.
prefixed by the length of the array (which is also variable length, Zigzag encoded)
i itself is also encoded so the decoded length shall be i / 2.
In the common case where a message is defined at top level (i.e. not nested within another message's definition), and the message index is <= 63, the current implement happens to work correctly because i == 2 implies i == 1 + i/2.
Example: UserWithNewType in the PR is at top level with index 2, so its indexes array [2] would be encoded as 02 04 (02 for the length 1 and 04 for the element 2). Skipping 02 (first byte read as i) bytes happens to skip the encoded sequence exactly.
The text was updated successfully, but these errors were encountered:
Note here:
As nesting depth of message and no. of messages can be larger than 2^6 - 1 (in varint encoding, only 7b out of 1B is for zig-zag encoding, so 63 is the max number that can be encoded in 1 byte), we need to check more bytes if the highest bit is 1.
The correct implementation may be:
if the first byte is not 0, decode one int as i with varint & zig-zag, and then decode i ints with varint & zig-zag. The remaining part is the actual payload.
Originally posted by @xiangjinwu in #14057 (comment)
Originally posted by @Rossil2012 in #14057 (comment)
Impact
In the common case where a message is defined at top level (i.e. not nested within another message's definition), and the message index is <= 63, the current implement happens to work correctly because
i == 2
impliesi == 1 + i/2
.Example:
UserWithNewType
in the PR is at top level with index 2, so its indexes array[2]
would be encoded as02 04
(02
for the length1
and04
for the element2
). Skipping02
(first byte read asi
) bytes happens to skip the encoded sequence exactly.The text was updated successfully, but these errors were encountered: