aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Build/Step/Compile.zig
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2023-08-02 15:51:58 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-08-02 20:20:48 -0700
commit76f7b40e15456ed6ec2249607a91e8398a0d39e8 (patch)
treee431420ddebd9e845e1b6870a4f921014c014697 /lib/std/Build/Step/Compile.zig
parent89d660c3ebed27996ac08c9cb3d75718d6a007db (diff)
downloadzig-76f7b40e15456ed6ec2249607a91e8398a0d39e8.tar.gz
zig-76f7b40e15456ed6ec2249607a91e8398a0d39e8.zip
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.
Diffstat (limited to 'lib/std/Build/Step/Compile.zig')
-rw-r--r--lib/std/Build/Step/Compile.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
index 8d6744062f..b414d43e27 100644
--- a/lib/std/Build/Step/Compile.zig
+++ b/lib/std/Build/Step/Compile.zig
@@ -1072,17 +1072,20 @@ pub fn addConfigHeader(self: *Compile, config_header: *Step.ConfigHeader) void {
}
pub fn addLibraryPath(self: *Compile, directory_source: LazyPath) void {
- self.lib_paths.append(directory_source) catch @panic("OOM");
+ const b = self.step.owner;
+ self.lib_paths.append(directory_source.dupe(b)) catch @panic("OOM");
directory_source.addStepDependencies(&self.step);
}
pub fn addRPath(self: *Compile, directory_source: LazyPath) void {
- self.rpaths.append(directory_source) catch @panic("OOM");
+ const b = self.step.owner;
+ self.rpaths.append(directory_source.dupe(b)) catch @panic("OOM");
directory_source.addStepDependencies(&self.step);
}
pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void {
- self.framework_dirs.append(directory_source) catch @panic("OOM");
+ const b = self.step.owner;
+ self.framework_dirs.append(directory_source.dupe(b)) catch @panic("OOM");
directory_source.addStepDependencies(&self.step);
}