mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Fix lexing out of bounds by one (#17168)
This commit is contained in:
@@ -391,6 +391,8 @@ function getBuildEnv(target, options) {
|
||||
ENABLE_ASSERTIONS: release ? "OFF" : "ON",
|
||||
ENABLE_LOGS: release ? "OFF" : "ON",
|
||||
ABI: abi === "musl" ? "musl" : undefined,
|
||||
|
||||
CMAKE_TLS_VERIFY: "0",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -798,11 +798,18 @@ fn NewLexer_(
|
||||
}
|
||||
|
||||
inline fn nextCodepointSlice(it: *LexerType) []const u8 {
|
||||
if (it.current >= it.source.contents.len) {
|
||||
return "";
|
||||
}
|
||||
const cp_len = strings.wtf8ByteSequenceLengthWithInvalid(it.source.contents.ptr[it.current]);
|
||||
return if (!(cp_len + it.current > it.source.contents.len)) it.source.contents[it.current .. cp_len + it.current] else "";
|
||||
}
|
||||
|
||||
inline fn nextCodepoint(it: *LexerType) CodePoint {
|
||||
if (it.current >= it.source.contents.len) {
|
||||
it.end = it.source.contents.len;
|
||||
return -1;
|
||||
}
|
||||
const cp_len = strings.wtf8ByteSequenceLengthWithInvalid(it.source.contents.ptr[it.current]);
|
||||
const slice = if (!(cp_len + it.current > it.source.contents.len)) it.source.contents[it.current .. cp_len + it.current] else "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user