From 3eb2dfe2eb782327daf7f5e567bf4f791bc578b8 Mon Sep 17 00:00:00 2001 From: rcombs Date: Fri, 10 Mar 2023 18:07:00 -0500 Subject: [PATCH] player/command: fix mem leak in user-data property; closes #11436 --- player/command.c | 5 +++++ 1 file changed, 5 insertions(+) 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);