mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
input: fix dangling pointer issues with multi-part commands
This didn't setup the linked list of sub-commands for multi-part commands ("a ; b ; c") correctly. Also, the new commands were attached to the allocation of the _old_ command instead of the new one. (Wow, whatever the hell I was (not) thinking when I wrote this code.)
This commit is contained in:
parent
4e7ab517c1
commit
837377a6ce
@ -1772,13 +1772,16 @@ mp_cmd_t *mp_cmd_clone(mp_cmd_t *cmd)
|
||||
}
|
||||
|
||||
if (cmd->id == MP_CMD_COMMAND_LIST) {
|
||||
bool first = true;
|
||||
struct mp_cmd *prev = NULL;
|
||||
for (struct mp_cmd *sub = cmd->args[0].v.p; sub; sub = sub->queue_next) {
|
||||
sub = mp_cmd_clone(sub);
|
||||
talloc_steal(cmd, sub);
|
||||
if (first)
|
||||
cmd->args[0].v.p = sub;
|
||||
first = false;
|
||||
talloc_steal(ret, sub);
|
||||
if (prev) {
|
||||
prev->queue_next = sub;
|
||||
} else {
|
||||
ret->args[0].v.p = sub;
|
||||
}
|
||||
prev = sub;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user