From 1c9d066c9eda7eee66d659f3e4aa839867d7972b Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Thu, 14 Nov 2024 18:10:00 -0500 Subject: [PATCH] input: fix memory leak with scalable input and nonscalable commands With scalable input source, scale_units can be 0, and cmd is not freed. Fix this by freeing cmd when scale_units is 0. Fixes: 937128697fbbef6b21e2d23a4785f1334f62b9e3 --- input/input.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/input/input.c b/input/input.c index 60b43e2032..98ca17b8b6 100644 --- a/input/input.c +++ b/input/input.c @@ -672,8 +672,11 @@ static void interpret_key(struct input_ctx *ictx, int code, double scale, scale_units = MPMIN(scale_units, 20); for (int i = 0; i < scale_units - 1; i++) queue_cmd(ictx, mp_cmd_clone(cmd)); - if (scale_units) + if (scale_units) { queue_cmd(ictx, cmd); + } else { + talloc_free(cmd); + } } }