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: 937128697f
This commit is contained in:
nanahi 2024-11-14 18:10:00 -05:00 committed by sfan5
parent 70aaba71d6
commit 1c9d066c9e
1 changed files with 4 additions and 1 deletions

View File

@ -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);
}
}
}