Fix use-after-free in argument parsing

Introduced in 53d3e4c112
This commit is contained in:
Yorhel 2021-10-06 14:06:48 +02:00
parent d1adcde15c
commit fdb93bb9e6

View file

@ -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()