From f279c5eba035d018a8805a65a8a245b8b8d2ea2e Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 24 Aug 2023 12:40:51 +0100 Subject: [PATCH] midend_request_keys: fix memory leak of a game_params. Thanks to Steffen Bauer for spotting this. The call to midend_get_params(me) was making a duplicate of me->params, and nothing was freeing it. Since the game_params is passed to request_keys as a const pointer, it should be safe to pass me->params itself, so that instead of adding a free, we can remove the unnecessary allocation. --- midend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/midend.c b/midend.c index d662d7a..34290cc 100644 --- a/midend.c +++ b/midend.c @@ -1271,7 +1271,7 @@ key_label *midend_request_keys(midend *me, int *n) if(me->ourgame->request_keys) { - keys = me->ourgame->request_keys(midend_get_params(me), &nkeys); + keys = me->ourgame->request_keys(me->params, &nkeys); for(i = 0; i < nkeys; ++i) { if(!keys[i].label)