35 lines
1.3 KiB
Diff
35 lines
1.3 KiB
Diff
From 3fa3a935bdacbcedccf51bea4b8b3c0a396b10ee Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Ingo=20Br=C3=BCckl?= <ib@oddnet.de>
|
|
Date: Tue, 15 Apr 2025 17:48:10 +0200
|
|
Subject: [PATCH] Prevent access to terminal data after it has been freed
|
|
|
|
After the last terminal child (tab) exits, all terminal data is freed.
|
|
Checking whether the number of terminal tabs is zero is a use-after-free
|
|
access.
|
|
|
|
This fixes github issue #131, reported by mtasaka.
|
|
---
|
|
src/lxterminal.c | 4 +++-
|
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/lxterminal.c b/src/lxterminal.c
|
|
index 5148b75..18ac81a 100644
|
|
--- a/src/lxterminal.c
|
|
+++ b/src/lxterminal.c
|
|
@@ -478,12 +478,14 @@ static void terminal_close_tab_activate_event(GtkAction * action, LXTerminal * t
|
|
* Close the current window. */
|
|
static void terminal_close_window_activate_event(GtkAction * action, LXTerminal * terminal)
|
|
{
|
|
+ guint len;
|
|
+
|
|
if (!terminal_close_window_confirmation_dialog(terminal)) {
|
|
return;
|
|
}
|
|
|
|
/* Play it safe and delete tabs one by one. */
|
|
- while(terminal->terms->len > 0) {
|
|
+ for (len = terminal->terms->len; len; len--) {
|
|
Term *term = g_ptr_array_index(terminal->terms, 0);
|
|
#if VTE_CHECK_VERSION (0, 38, 0)
|
|
terminal_child_exited_event(VTE_TERMINAL(term->vte), 0, term);
|