fix(terminal): possible memory leak on exit (#37532)

Problem:
On exit, it's possible that term_delayed_free() hasn't been called yet
when the main loop is freed, in which case it won't be called ever.

Solution:
Don't bail out with term->destroy set when calling terminal_close()
inside free_all_mem().
This commit is contained in:
zeertzjq
2026-01-24 11:32:52 +08:00
committed by GitHub
parent 813a6d3b11
commit 72ac9ac9a1

View File

@@ -583,9 +583,6 @@ void terminal_close(Terminal **termpp, int status)
FUNC_ATTR_NONNULL_ALL
{
Terminal *term = *termpp;
if (term->destroy) {
return;
}
#ifdef EXITFREE
if (entered_free_all_mem) {
@@ -596,6 +593,10 @@ void terminal_close(Terminal **termpp, int status)
}
#endif
if (term->destroy) { // Destruction already scheduled on the main loop.
return;
}
bool only_destroy = false;
if (term->closed) {