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 {...@@ -1072,17 +1072,20 @@ pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {
1072}1072}
10731073
1074pub fn addLibraryPath(self: *Compile, directory_source: LazyPath) void {1074pub 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");
1076 directory_source.addStepDependencies(&self.step);1077 directory_source.addStepDependencies(&self.step);
1077}1078}
10781079
1079pub fn addRPath(self: *Compile, directory_source: LazyPath) void {1080pub 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");
1081 directory_source.addStepDependencies(&self.step);1083 directory_source.addStepDependencies(&self.step);
1082}1084}
10831085
1084pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void {1086pub 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");
1086 directory_source.addStepDependencies(&self.step);1089 directory_source.addStepDependencies(&self.step);
1087}1090}
10881091