This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository terminology.
View the commit online.
commit cba3802fc085bb2bd335d722c12c8cec48ef77b1
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 20 12:41:35 2026 -0600
termpty: release the cells a resize cuts off the inactive screen
The inactive screen is not rewrapped on resize, only copied, cut to the
new size. The cells it lost kept their link and block references, so a
link or a block that only they showed was never freed: a full-screen
program that put a hyperlink near the right edge and was then narrowed
held that link for the life of the terminal.
The inactive screen is now copied the way the active one is rewrapped:
the copy takes references for the cells it keeps, and the old screen
gives back all of its own before it is freed.
---
src/bin/termpty.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++---
src/bin/tytest.c | 1 +
src/bin/unit_tests.h | 1 +
3 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 2ad39bc4..7425ddce 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1632,10 +1632,12 @@ termpty_resize(Termpty *ty, int new_w, int new_h)
{
int src_y = (y + ty->circular_offset2) % old_h;
- memcpy(&ty->screen2[y * new_w],
- &old_screen2[src_y * old_w],
- copy_w * sizeof(Termcell));
+ TERMPTY_CELL_COPY(ty, &old_screen2[src_y * old_w],
+ &ty->screen2[y * new_w], copy_w);
}
+ /* the copy took references for the cells it kept, the cells cut
+ * off give theirs back with the rest */
+ _cells_refs_release(ty, old_screen2, old_w * old_h);
}
free(old_screen2);
@@ -4883,4 +4885,50 @@ tytest_resize_screen_block_refs(void)
}
#endif
+#if defined(BINARY_TYTEST)
+/* A resize that shrinks the inactive screen drops the cells it cuts off:
+ * a link or a block only they showed is freed, a link still shown keeps
+ * its count. */
+int
+tytest_resize_screen2_link_refs(void)
+{
+ const Termcell *cells;
+ Termblock *blk;
+ Termpty ty;
+ ssize_t w = 0;
+ uint16_t kept_id, cut_id;
+ int blk_id;
+
+ _ty_test_init(&ty, 10, 3);
+ blk = termpty_block_new(&ty, 1, 1, "/img.png", NULL);
+ assert(blk);
+ blk_id = blk->id;
+ termpty_block_insert(&ty, '#', blk);
+ _ty_feed(&ty, "\033[?1049h"
+ "\033]8;;http://kept\033\\KK\033]8;;\033\\"
+ "\033[1;9H\033]8;;http://cut\033\\CC\033]8;;\033\\");
+ ty.block.on = EINA_TRUE;
+ _ty_feed(&ty, "\033[2;9H#");
+ ty.block.on = EINA_FALSE;
+ assert(blk->refs == 1);
+ cells = termpty_cellrow_get(&ty, 0, &w);
+ kept_id = cells[0].att.link_id;
+ cut_id = cells[8].att.link_id;
+ assert(kept_id && cut_id && (kept_id != cut_id));
+ assert(ty.hl.links[cut_id].refcount == 2);
+
+ termpty_resize(&ty, 6, 3);
+ assert(ty.hl.links[kept_id].refcount == 2);
+ assert(ty.hl.links[kept_id].url);
+ assert(ty.hl.links[cut_id].refcount == 0);
+ assert(!ty.hl.links[cut_id].url);
+ assert(!termpty_block_get(&ty, blk_id));
+
+ _ty_test_shutdown(&ty);
+ eina_hash_free(ty.block.blocks);
+ free(ty.hl.links);
+ return 0;
+}
+#endif
+
#endif /* BINARY_TYFUZZ || BINARY_TYTEST */
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index b8613b76..a789e9a0 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -80,6 +80,7 @@ static struct {
{ "resize_wrapped_link", tytest_resize_wrapped_link},
{ "resize_screen_link_refs", tytest_resize_screen_link_refs},
{ "resize_screen_block_refs", tytest_resize_screen_block_refs},
+ { "resize_screen2_link_refs", tytest_resize_screen2_link_refs},
{ "percent_decode", tytest_percent_decode},
{ "sgr_58_no_leak", tytest_sgr_58_no_leak},
{ "xmodkeys_set", tytest_xmodkeys_set},
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 60198949..d30a8ffc 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -53,6 +53,7 @@ int tytest_links_reset(void);
int tytest_resize_wrapped_link(void);
int tytest_resize_screen_link_refs(void);
int tytest_resize_screen_block_refs(void);
+int tytest_resize_screen2_link_refs(void);
int tytest_percent_decode(void);
int tytest_sgr_58_no_leak(void);
int tytest_xmodkeys_set(void);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.