From 9244e4fe2d675c6cda569afc7509349e35199ed5 Mon Sep 17 00:00:00 2001 From: kcbanner Date: Sat, 27 May 2023 15:07:44 -0400 Subject: [PATCH] cache: handle 0-length prefix paths in findPrefixResolved --- lib/std/Build/Cache.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig index 4db8f18a31..de68ef6644 100644 --- a/lib/std/Build/Cache.zig +++ b/lib/std/Build/Cache.zig @@ -123,7 +123,7 @@ fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath { var i: u8 = 1; // Start at 1 to skip over checking the null prefix. while (i < prefixes_slice.len) : (i += 1) { const p = prefixes_slice[i].path.?; - if (mem.startsWith(u8, resolved_path, p)) { + if (p.len > 0 and mem.startsWith(u8, resolved_path, p)) { // +1 to skip over the path separator here const sub_path = try gpa.dupe(u8, resolved_path[p.len + 1 ..]); gpa.free(resolved_path);