mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 21:01:52 +00:00
fix decoding invalid UTF-8 input (#3563)
* fix decoding invalid UTF-8 input Close: https://github.com/oven-sh/bun/issues/3562 * add unittest
This commit is contained in:
@@ -129,7 +129,7 @@ uint8_t JSStringDecoder::utf8CheckIncomplete(uint8_t* bufPtr, uint32_t length, u
|
||||
m_lastNeed = nb - 1;
|
||||
return nb;
|
||||
}
|
||||
if (--j < i || nb == -2)
|
||||
if (j == 0 || --j < i || nb == -2)
|
||||
return 0;
|
||||
nb = utf8CheckByte(bufPtr[j]);
|
||||
if (nb >= 0) {
|
||||
@@ -137,7 +137,7 @@ uint8_t JSStringDecoder::utf8CheckIncomplete(uint8_t* bufPtr, uint32_t length, u
|
||||
m_lastNeed = nb - 2;
|
||||
return nb;
|
||||
}
|
||||
if (--j < i || nb == -2)
|
||||
if (j == 0 || --j < i || nb == -2)
|
||||
return 0;
|
||||
nb = utf8CheckByte(bufPtr[j]);
|
||||
if (nb >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user