mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-11 07:03:33 +02:00
ShiftJIS: don't consume the null terminator as a second byte
next() would read a truncated lead byte's "second byte" unconditionally, even when that byte was actually the string's null terminator - leaving index_ one past the terminator, so a subsequent end()/next() call read one byte out of bounds. Now checks for the terminator before consuming it, returning INVALID without advancing past it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
406033dc3d
commit
c45ceb6e2f
@@ -43,6 +43,11 @@ struct ShiftJIS {
|
||||
}
|
||||
|
||||
// Okay, if we didn't return, it's time for the second byte (the cell.)
|
||||
if (c_[index_] == 0) {
|
||||
// Truncated sequence right at the end of the string - don't consume the
|
||||
// terminator, or index_ would end up one past it (OOB on the next call).
|
||||
return INVALID;
|
||||
}
|
||||
j = (uint8_t)c_[index_++];
|
||||
// Not a valid second byte.
|
||||
if (j < 0x40 || j == 0x7F || j >= 0xFD) {
|
||||
|
||||
Reference in New Issue
Block a user