summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2023-03-10 18:07:00 -0500
committerrcombs <rcombs@rcombs.me>2023-03-13 22:49:51 -0400
commit3eb2dfe2eb782327daf7f5e567bf4f791bc578b8 (patch)
treed2c89143d3cfc401ca5a5205b3ba6089eca6a194 /player/command.c
parent3a2f8d42ab203c961e50ce198ca4eb232de3819a (diff)
downloadmpv-3eb2dfe2eb782327daf7f5e567bf4f791bc578b8.tar.bz2
mpv-3eb2dfe2eb782327daf7f5e567bf4f791bc578b8.tar.xz
player/command: fix mem leak in user-data property; closes #11436
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 51503ca504..53260074ad 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3578,6 +3578,7 @@ struct udata_ctx {
MPContext *mpctx;
const char *path;
mpv_node *node;
+ void *ta_parent;
};
static int do_op_udata(struct udata_ctx* ctx, int action, void *arg)
@@ -3603,6 +3604,7 @@ static int do_op_udata(struct udata_ctx* ctx, int action, void *arg)
case M_PROPERTY_SET_NODE:
assert(node);
m_option_copy(&udata_type, node, arg);
+ talloc_steal(ctx->ta_parent, node_get_alloc(node));
mp_notify_property(mpctx, ctx->path);
return M_PROPERTY_OK;
case M_PROPERTY_KEY_ACTION: {
@@ -3678,6 +3680,7 @@ static int do_op_udata(struct udata_ctx* ctx, int action, void *arg)
struct udata_ctx nctx = *ctx;
nctx.node = cnode;
+ nctx.ta_parent = node_get_alloc(node);
// If we're going down another level, set up a new key-action.
if (has_split) {
@@ -3700,6 +3703,7 @@ static int do_list_udata(int item, int action, void *arg, void *ctx)
{
struct udata_ctx nctx = *(struct udata_ctx*)ctx;
nctx.node = &nctx.node->u.list->values[item];
+ nctx.ta_parent = &nctx.node->u.list;
return do_op_udata(&nctx, action, arg);
}
@@ -3725,6 +3729,7 @@ static int mp_property_udata(void *ctx, struct m_property *prop,
.mpctx = mpctx,
.path = path,
.node = &mpctx->command_ctx->udata,
+ .ta_parent = &mpctx->command_ctx,
};
int ret = do_op_udata(&nctx, action, arg);