From 88c1b0ffc1432d369f2058634feb9ddf18c46d03 Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Fri, 12 Apr 2024 14:53:22 -0700 Subject: [PATCH] Source: check for truncated utf-8 codepoint at EOF --- src/aro/Source.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/aro/Source.zig b/src/aro/Source.zig index 06e58ecb..af72e6d8 100644 --- a/src/aro/Source.zig +++ b/src/aro/Source.zig @@ -75,6 +75,10 @@ pub fn lineCol(source: Source, loc: Location) LineCol { i += 1; continue; }; + const slice = source.buf[i..]; + if (len > slice.len) { + break; + } const cp = std.unicode.utf8Decode(source.buf[i..][0..len]) catch { i += 1; continue;