diff options
author | wm4 <wm4@nowhere> | 2013-07-24 19:43:31 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-07-24 19:43:31 +0200 |
commit | 837377a6ce8b7088aa6f8dba639a84dc4949338b (patch) | |
tree | 80df18506507576753be204f5e5ad33ff27b7b80 /core/input | |
parent | 4e7ab517c182f87a4927e22b6af4a36204f4c6eb (diff) | |
download | mpv-837377a6ce8b7088aa6f8dba639a84dc4949338b.tar.bz2 mpv-837377a6ce8b7088aa6f8dba639a84dc4949338b.tar.xz |
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.)
Diffstat (limited to 'core/input')
-rw-r--r-- | core/input/input.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/input/input.c b/core/input/input.c index 183cec7f09..7a016a0e4f 100644 --- a/core/input/input.c +++ b/core/input/input.c @@ -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; } } |