stage2: fix UAF of system_libs

This commit is contained in:
Andrew Kelley 2021-12-30 23:14:34 -07:00
parent 55243cfb31
commit 9dc25dd0b6
2 changed files with 7 additions and 1 deletions

View File

@ -1985,7 +1985,7 @@ pub fn update(comp: *Compilation) !void {
// This resets the link.File to operate as if we called openPath() in create()
// instead of simulating -fno-emit-bin.
var options = comp.bin_file.options;
var options = comp.bin_file.options.move();
if (comp.whole_bin_sub_path) |sub_path| {
options.emit = .{
.directory = tmp_artifact_directory.?,

View File

@ -167,6 +167,12 @@ pub const Options = struct {
pub fn effectiveOutputMode(options: Options) std.builtin.OutputMode {
return if (options.use_lld) .Obj else options.output_mode;
}
pub fn move(self: *Options) Options {
const copied_state = self.*;
self.system_libs = .{};
return copied_state;
}
};
pub const File = struct {