From fdb93bb9e646fad0c763be43a53c11b2543bdcbe Mon Sep 17 00:00:00 2001 From: Yorhel <git@yorhel.nl> Date: Wed, 6 Oct 2021 14:06:48 +0200 Subject: [PATCH] Fix use-after-free in argument parsing Introduced in 53d3e4c112a475ecbaae42cc1e58d42b986d76fc --- src/main.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index b8f19a5..bf210dc 100644 --- a/src/main.zig +++ b/src/main.zig @@ -429,7 +429,7 @@ pub fn main() void { if (!opt.opt) { // XXX: ncdu 1.x doesn't error, it just silently ignores all but the last argument. if (scan_dir != null) ui.die("Multiple directories given, see ncdu -h for help.\n", .{}); - scan_dir = opt.val; + scan_dir = allocator.dupeZ(u8, opt.val) catch unreachable; continue; } if (opt.is("-h") or opt.is("-?") or opt.is("--help")) help() -- GitLab