zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 76f7b40e15456ed6ec2249607a91e8398a0d39e8 (tree)
parent 89d660c3ebed27996ac08c9cb3d75718d6a007db
Author: Mitchell Hashimoto <mitchell.hashimoto@gmail.com>
Date:   Wed,  2 Aug 2023 15:51:58 -0700

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:
Mlib/std/Build/Step/Compile.zig | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git 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); }