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.
This commit is contained in:
Simon Tatham
2023-08-24 12:40:51 +01:00
parent 56781e60ba
commit f279c5eba0

View File

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