fix use-after-free on repl
This commit is contained in:
parent
f61e9b013f
commit
708ef45600
1 changed files with 4 additions and 2 deletions
|
@ -60,9 +60,11 @@ pub fn doRepl(allocator: *std.mem.Allocator, args_it: anytype) !void {
|
|||
var scri_existing = try allocator.alloc(u8, total_bytes);
|
||||
_ = try file_read_opt.?.read(scri_existing);
|
||||
|
||||
// we can defer this because we copy the Command structs back to cmds
|
||||
// we can't defer this directly because we copy the
|
||||
// Command pointers to the cmds list. running deinit() directly
|
||||
// would cause those pointers to be freed.
|
||||
var existing_cmds = try lang.parse(scri_existing);
|
||||
defer existing_cmds.deinit();
|
||||
defer existing_cmds.list.deinit();
|
||||
|
||||
// copy the existing command list into the repl's command list
|
||||
for (existing_cmds.list.items) |existing_cmd| {
|
||||
|
|
Loading…
Reference in a new issue