Skip to content

Commit

Permalink
tokenizer: fix 0 byte following invalid (ziglang#21482)
Browse files Browse the repository at this point in the history
  • Loading branch information
igor84 authored and DivergentClouds committed Sep 24, 2024
1 parent 10c0dec commit 9df598a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/std/zig/tokenizer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,8 @@ pub const Tokenizer = struct {
switch (self.buffer[self.index]) {
0 => if (self.index == self.buffer.len) {
result.tag = .invalid;
} else {
continue :state .invalid;
},
'\n' => result.tag = .invalid,
else => continue :state .invalid,
Expand Down Expand Up @@ -1250,6 +1252,7 @@ test "invalid token characters" {

test "invalid literal/comment characters" {
try testTokenize("\"\x00\"", &.{.invalid});
try testTokenize("`\x00`", &.{.invalid});
try testTokenize("//\x00", &.{.invalid});
try testTokenize("//\x1f", &.{.invalid});
try testTokenize("//\x7f", &.{.invalid});
Expand Down

0 comments on commit 9df598a

Please sign in to comment.