From: "Omar Polo" Subject: Re: leak in mg, interpreter.c:599 To: Han Boetes Cc: tech@openbsd.org Date: Sun, 22 Feb 2026 11:34:47 +0100 Hello, Han Boetes wrote: > While playing around with valgrind and mg I noticed some leaks. > First, I created a test init-file with the contents: > > (define myvar "hello") > (define myvar "world") > > After which something is leaking in interpreter.c at line 599, see > valgrind output below. > > Upon redefinition of a variable, the old varentry and its v_name string > are not freed. Additionally, SLIST_INSERT_HEAD is called before strndup > succeeds, meaning a failed strndup leaves a partially initialised entry > in the live list. > The following patch fixes both issues. With it applied, the > interpreter.c leak in the valgrind output below disappears. Thanks for the diff! I was a bit confused why v_vals was not freed as well, but it seems it's never used (just set to NULL), so I've left it as-is for now. Just fyi: the diff was mangled by the mua, and the indentation seemed a bit off, so I had to hand-apply it. Thanks! Omar Polo