Skip to content

Commit

Permalink
Fix lexing out of bounds by one (#17168)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-conway authored Feb 8, 2025
1 parent 584db03 commit 2644bad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .buildkite/ci.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
};
}

Expand Down
7 changes: 7 additions & 0 deletions src/js_lexer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";

Expand Down

0 comments on commit 2644bad

Please sign in to comment.