LiangliangSui commented on code in PR #1650: URL: https://github.com/apache/incubator-fury/pull/1650#discussion_r1618808382
########## java/fury-core/src/main/java/org/apache/fury/memory/MemoryBuffer.java: ########## @@ -1774,7 +1774,7 @@ private long readVarUint36Slow() { /** Reads the 1-5 byte int part of a non-negative varint. */ public int readVarUint32() { int readIdx = readerIndex; - if (size - readIdx < 5) { + if (size - readIdx < 4) { Review Comment: > later result |= (UNSAFE.getByte(heapMemory, address + readIdx++) & 0x7F) << 28; wqill read one more byte without check. If we lower threshold, we may get crash in such cases. The premise for executing `result |= (UNSAFE.getByte(heapMemory, address + readIdx++) & 0x7F) << 28` is that the fourth byte of `fourByteValue` is `0b1xxxxxxxx` (that is, there are more bytes to be parsed). In `readVarUint36Slow()`, it is also possible to read 5 bytes continuously (provided that `(b & 0x80) != 0`). Therefore, the premise of executing `result |= (UNSAFE.getByte(heapMemory, address + readIdx++) & 0x7F) << 28` is that we still have content that can be read in the Buffer. If there is no content to read, it means that an error occurred during writing. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@fury.apache.org For additional commands, e-mail: commits-h...@fury.apache.org