diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2023-08-02 15:51:58 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-08-02 20:20:48 -0700 |
| commit | 76f7b40e15456ed6ec2249607a91e8398a0d39e8 (patch) | |
| tree | e431420ddebd9e845e1b6870a4f921014c014697 /lib/std/Build/Step/Compile.zig | |
| parent | 89d660c3ebed27996ac08c9cb3d75718d6a007db (diff) | |
| download | zig-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.zig | 9 |
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); } |
