Skip to content

Commit

Permalink
input: fix memory leak with scalable input and nonscalable commands
Browse files Browse the repository at this point in the history
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: 9371286
  • Loading branch information
na-na-hi committed Nov 14, 2024
1 parent 43d8966 commit 24ed213
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 24ed213

Please sign in to comment.