jonyoder commented on code in PR #3293:
URL: https://github.com/apache/fory/pull/3293#discussion_r2772062944
##########
go/fory/string.go:
##########
@@ -84,9 +84,13 @@ func readUTF16LE(buf *ByteBuffer, byteCount int, err *Error)
string {
data := buf.ReadBinary(byteCount, err)
// Reconstruct UTF-16 code units
+ // Note: byteCount should always be even for valid UTF-16, but handle
odd counts
+ // gracefully to avoid index out of range panics from malformed data.
charCount := byteCount / 2
u16s := make([]uint16, charCount)
- for i := 0; i < byteCount; i += 2 {
+ // Only iterate up to the last complete pair (round down to even
boundary)
+ evenByteCount := byteCount &^ 1
Review Comment:
Sorry about the delay. I stepped back to try to figure out the exact source
of this issue in our case, and I've been having trouble reproducing it again! I
see you've pushed another commit; nice to see that this will be handled
correctly either way!
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]