This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch desktop-restore
in repository terminology.

View the commit online.

commit 279a7516624860582db86495caffcc6eb7ff5ba4
Author: [email protected] <[email protected]>
AuthorDate: Fri Mar 20 11:40:55 2026 -0600

    fix: address resource leaks and NULL pointer dereferences in session restore
    
    Three defensive programming fixes from code review:
    
    1. session.c: _restore_stub() SPLIT case now properly frees tc1 and tc2
       via _tc_tree_close when win_split_new fails, preventing resource leak.
    
    2. win.c: win_has_single_child() now guards against NULL wn->child
       before dereferencing, preventing potential crash.
    
    3. session.c: session_defer_show_begin() now asserts !_defer_show to
       enforce non-reentrancy requirement and prevent state corruption.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 src/bin/session.c | 11 +++++++++--
 src/bin/win.c     |  2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/bin/session.c b/src/bin/session.c
index 9bbdc788..cf18e2eb 100644
--- a/src/bin/session.c
+++ b/src/bin/session.c
@@ -1,5 +1,6 @@
 #include "private.h"
 
+#include <assert.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -779,8 +780,13 @@ _restore_stub(Session_Node *node, Win *wn,
               Term_Container *split_tc = win_split_new(tc1, tc2,
                                                        node->split_ratio,
                                                        node->is_horizontal);
-              if (split_tc)
-                win_split_set_last_focus(split_tc, node->active_tab);
+              if (!split_tc)
+                {
+                   _tc_tree_close(tc1, wn);
+                   _tc_tree_close(tc2, wn);
+                   return NULL;
+                }
+              win_split_set_last_focus(split_tc, node->active_tab);
               return split_tc;
            }
         }
@@ -1449,6 +1455,7 @@ session_meta_list_free(Eina_List *list)
 void
 session_defer_show_begin(void)
 {
+   assert(!_defer_show);
    _defer_show = EINA_TRUE;
 }
 
diff --git a/src/bin/win.c b/src/bin/win.c
index cd03a70d..a525a322 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -1728,7 +1728,7 @@ Eina_Bool
 win_has_single_child(const Win *wn)
 {
    const Term_Container *child = wn->child;
-
+   if (!child) return EINA_FALSE;
    return (child->type == TERM_CONTAINER_TYPE_SOLO);
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to