authorgravatar for mitchell.hashimoto@gmail.comMitchell Hashimoto <mitchell.hashimoto@gmail.com> 2023-08-02 15:51:58-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-02 20:20:48-07:00
log76f7b40e15456ed6ec2249607a91e8398a0d39e8
treee431420ddebd9e845e1b6870a4f921014c014697
parent89d660c3ebed27996ac08c9cb3d75718d6a007db

build: dupe library, rpath, and framework LazyPaths

Without duping, users could get some unexpected behavior if they used a string with a lifetime that didn't persist throughout the full build, i.e. if it wasn't heap allocated, or if it was explicitly freed.

1 files changed, 6 insertions(+), 3 deletions(-)

lib/std/Build/Step/Compile.zig+6-3
......@@ -1072,17 +1072,20 @@ pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {
10721072}
10731073
10741074pub fn addLibraryPath(self: *Compile, directory_source: LazyPath) void {
1075 self.lib_paths.append(directory_source) catch @panic("OOM");
1075 const b = self.step.owner;
1076 self.lib_paths.append(directory_source.dupe(b)) catch @panic("OOM");
10761077 directory_source.addStepDependencies(&self.step);
10771078}
10781079
10791080pub fn addRPath(self: *Compile, directory_source: LazyPath) void {
1080 self.rpaths.append(directory_source) catch @panic("OOM");
1081 const b = self.step.owner;
1082 self.rpaths.append(directory_source.dupe(b)) catch @panic("OOM");
10811083 directory_source.addStepDependencies(&self.step);
10821084}
10831085
10841086pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void {
1085 self.framework_dirs.append(directory_source) catch @panic("OOM");
1087 const b = self.step.owner;
1088 self.framework_dirs.append(directory_source.dupe(b)) catch @panic("OOM");
10861089 directory_source.addStepDependencies(&self.step);
10871090}
10881091