0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02: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:
wm4 2013-07-24 19:43:31 +02:00
parent 4e7ab517c1
commit 837377a6ce

View File

@ -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;
}
}