aboutsummaryrefslogtreecommitdiff
path: root/std/build.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-05-02 18:22:08 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-05-02 18:22:08 -0400
commitf87be94f6a4277823eeaab12cd581fd5cedff19b (patch)
treefcaa7a53653aa6b2c971c98290da7555113279a9 /std/build.zig
parentf69d28a0875effbfbd704f3ca7947c95eae05e2f (diff)
downloadzig-f87be94f6a4277823eeaab12cd581fd5cedff19b.tar.gz
zig-f87be94f6a4277823eeaab12cd581fd5cedff19b.zip
zig build: copy args for addCommand
avoids making it easy to accidentally use a dangling pointer
Diffstat (limited to 'std/build.zig')
-rw-r--r--std/build.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/std/build.zig b/std/build.zig
index 4001aa4259..e6a1c06f20 100644
--- a/std/build.zig
+++ b/std/build.zig
@@ -178,6 +178,7 @@ pub const Builder = struct {
return CLibExeObjStep.createObject(self, name, src);
}
+ /// ::args are copied.
pub fn addCommand(self: &Builder, cwd: ?[]const u8, env_map: &const BufMap,
path: []const u8, args: []const []const u8) -> &CommandStep
{
@@ -1469,10 +1470,11 @@ pub const CommandStep = struct {
step: Step,
builder: &Builder,
exe_path: []const u8,
- args: []const []const u8,
+ args: [][]const u8,
cwd: ?[]const u8,
env_map: &const BufMap,
+ /// ::args are copied.
pub fn create(builder: &Builder, cwd: ?[]const u8, env_map: &const BufMap,
exe_path: []const u8, args: []const []const u8) -> &CommandStep
{
@@ -1481,10 +1483,11 @@ pub const CommandStep = struct {
.builder = builder,
.step = Step.init(exe_path, builder.allocator, make),
.exe_path = exe_path,
- .args = args,
+ .args = %%builder.allocator.alloc([]u8, args.len),
.cwd = cwd,
.env_map = env_map,
};
+ mem.copy([]const u8, self.args, args);
return self;
}