From d2fb3fb16b8c8254cb50031512cdb2c117fdb665 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Fri, 3 Mar 2023 14:53:32 +0100 Subject: [PATCH] Prevent memory leak. Remove use controls. Safeguard against NULL. --- src/frontend/inp.c | 3 ++- src/sharedspice.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index bf6d954d5..38118347a 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -1122,7 +1122,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile) inputdir = dir_name; #endif if (cp_getvar("controlswait", CP_BOOL, NULL, 0)) { - exec_controls(wl_copy(wl)); + if (wl) + exec_controls(wl_copy(wl)); break; } else diff --git a/src/sharedspice.c b/src/sharedspice.c index 4d7e52514..af9dccd02 100644 --- a/src/sharedspice.c +++ b/src/sharedspice.c @@ -485,6 +485,7 @@ _cthread_run(void *controls) #ifdef HAVE_LIBPTHREAD cont_condition = FALSE; #endif + wl_free(controls); return NULL; } @@ -608,6 +609,7 @@ exec_controls(wordlist *newcontrols) wordlist *wl; for (wl = shcontrols; wl; wl = wl->wl_next) cp_evloop(wl->wl_word); + wl_free(shcontrols); #endif }