diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-04-08 12:44:42 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2024-04-08 13:24:08 -0400 |
| commit | 7611d90ba011fb030523e669e85acfb6faae5d19 (patch) | |
| tree | f1b48f3ac73681c402dce10b5857ecc0f84dd7a4 /src/Compilation.zig | |
| parent | 4cd92567e7392b0fe390562d7ea52f68357bb45a (diff) | |
| download | zig-7611d90ba011fb030523e669e85acfb6faae5d19.tar.gz zig-7611d90ba011fb030523e669e85acfb6faae5d19.zip | |
InternPool: remove slice from byte aggregate keys
This deletes a ton of lookups and avoids many UAF bugs.
Closes #19485
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index c533f2fae7..5395be9f32 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3159,7 +3159,7 @@ pub fn addModuleErrorMsg(mod: *Module, eb: *ErrorBundle.Wip, module_err_msg: Mod const rt_file_path = try module_reference.src_loc.file_scope.fullPath(gpa); defer gpa.free(rt_file_path); ref_traces.appendAssumeCapacity(.{ - .decl_name = try eb.addString(ip.stringToSlice(module_reference.decl)), + .decl_name = try eb.addString(module_reference.decl.toSlice(ip)), .src_loc = try eb.addSourceLocation(.{ .src_path = try eb.addString(rt_file_path), .span_start = span.start, @@ -4074,8 +4074,7 @@ fn workerCheckEmbedFile( fn detectEmbedFileUpdate(comp: *Compilation, embed_file: *Module.EmbedFile) !void { const mod = comp.module.?; const ip = &mod.intern_pool; - const sub_file_path = ip.stringToSlice(embed_file.sub_file_path); - var file = try embed_file.owner.root.openFile(sub_file_path, .{}); + var file = try embed_file.owner.root.openFile(embed_file.sub_file_path.toSlice(ip), .{}); defer file.close(); const stat = try file.stat(); @@ -4444,7 +4443,7 @@ fn reportRetryableEmbedFileError( const ip = &mod.intern_pool; const err_msg = try Module.ErrorMsg.create(gpa, src_loc, "unable to load '{}{s}': {s}", .{ embed_file.owner.root, - ip.stringToSlice(embed_file.sub_file_path), + embed_file.sub_file_path.toSlice(ip), @errorName(err), }); |
