The GitHub Actions job "Fory CI" on fory.git/fix/go-utf16le-odd-bytecount has 
succeeded.
Run started by GitHub user jonyoder (triggered by jonyoder).

Head commit for run:
6fff8adaf3f56c09fa6eed4f422c077c6ebf038d / Jonathan Yoder 
<[email protected]>
fix(go): prevent panic in readUTF16LE with odd byte counts

When readUTF16LE receives an odd byte count (which indicates malformed
UTF-16 data), the function would panic with "index out of range" because
the loop iterated up to byteCount but tried to access data[i+1] on the
last iteration.

This fix rounds down to the nearest even byte boundary before iterating,
gracefully handling malformed data by ignoring the trailing byte instead
of panicking.

Fixes the panic:
  runtime error: index out of range [N] with length N

Added test cases:
- TestReadUTF16LE_OddByteCount: verifies no panic with odd byte count
- TestReadUTF16LE_SingleByte: verifies empty string for single byte
- TestReadUTF16LE_EvenByteCount: verifies normal case still works
- TestReadUTF16LE_EmptyBuffer: verifies empty input handling
- TestReadUTF16LE_SurrogatePair: verifies emoji/surrogate pair decoding

Co-Authored-By: Claude Opus 4.5 <[email protected]>

Report URL: https://github.com/apache/fory/actions/runs/21712527001

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to