From 837377a6ce8b7088aa6f8dba639a84dc4949338b Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 24 Jul 2013 19:43:31 +0200 Subject: 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.) --- core/input/input.c | 13 ++++++++----- 1 file 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; } } -- cgit v1.2.3