From 344ed6f9e05cfd1dd18f05d3ffefd0207d9bfafe Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 1 Jun 2026 19:56:26 +0000 Subject: [PATCH] Only set saved_layout_cell if creating a new cell, avoids crash when respawning pane. Reported by Mingjie Shen in GitHubb issue 5143. --- usr.bin/tmux/spawn.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/usr.bin/tmux/spawn.c b/usr.bin/tmux/spawn.c index 352f6f2722d..6f9b66660cd 100644 --- a/usr.bin/tmux/spawn.c +++ b/usr.bin/tmux/spawn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spawn.c,v 1.37 2026/05/19 10:26:03 nicm Exp $ */ +/* $OpenBSD: spawn.c,v 1.38 2026/06/01 19:56:26 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott @@ -271,23 +271,25 @@ spawn_pane(struct spawn_context *sc, char **cause) sc->wp0->ictx = NULL; new_wp = sc->wp0; new_wp->flags &= ~(PANE_STATUSREADY|PANE_STATUSDRAWN); - } else if (sc->lc == NULL) { - new_wp = window_add_pane(w, NULL, hlimit, sc->flags); - layout_init(w, new_wp); } else { - new_wp = window_add_pane(w, sc->wp0, hlimit, sc->flags); - if (sc->flags & SPAWN_ZOOM) - layout_assign_pane(sc->lc, new_wp, 1); - else - layout_assign_pane(sc->lc, new_wp, 0); - } + if (sc->lc == NULL) { + new_wp = window_add_pane(w, NULL, hlimit, sc->flags); + layout_init(w, new_wp); + } else { + new_wp = window_add_pane(w, sc->wp0, hlimit, sc->flags); + if (sc->flags & SPAWN_ZOOM) + layout_assign_pane(sc->lc, new_wp, 1); + else + layout_assign_pane(sc->lc, new_wp, 0); + } - /* - * If window currently zoomed, window_set_active_pane calls - * window_unzoom which it copies back the saved_layout_cell. - */ - if (w->flags & WINDOW_ZOOMED) - new_wp->saved_layout_cell = new_wp->layout_cell; + /* + * If window currently zoomed, window_set_active_pane calls + * window_unzoom which it copies back the saved_layout_cell. + */ + if (w->flags & WINDOW_ZOOMED) + new_wp->saved_layout_cell = new_wp->layout_cell; + } /* * Now we have a pane with nothing running in it ready for the new