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 38c612c29ef878d216c0741fd82f7fd9cb484e7a
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 20 12:34:38 2026 -0600
termpty: release the old screen's links on resize
A resize rewraps the screen into a new one, and the copy takes a
reference on the hyperlink of every cell it moves. The old screen was
then freed without giving its own references back, so each resize
added the cells of every link on screen to its count: a 4-cell link
went to 8, then 12. Such a link was never freed, even once nothing
showed it, and a terminal that had been resized with a link on screen
never got its link table dropped by RIS.
The old screen now gives its references back before it is freed.
---
src/bin/termpty.c | 35 +++++++++++++++++++++++++++++++++++
src/bin/tytest.c | 1 +
src/bin/unit_tests.h | 1 +
3 files changed, 37 insertions(+)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index 31ec75b9..a2f8edc7 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -1694,6 +1694,8 @@ termpty_resize(Termpty *ty, int new_w, int new_h)
old_y == ty->cursor_state.cy);
}
+ /* the rewrap took references for the cells it copied */
+ _cells_links_ref(ty, ty->screen, old_w * old_h, EINA_FALSE);
free(ty->screen);
ty->screen = new_screen;
@@ -4800,4 +4802,37 @@ tytest_resize_wrapped_link(void)
}
#endif
+#if defined(BINARY_TYTEST)
+/* A resize moves the screen's cells to a new screen: the links they hold
+ * keep the count of cells that show them, so that a reset can still free
+ * them and drop the link table. */
+int
+tytest_resize_screen_link_refs(void)
+{
+ const Termcell *cells;
+ Termpty ty;
+ ssize_t w = 0;
+ uint16_t link_id;
+
+ _ty_test_init(&ty, 10, 3);
+ _ty_feed(&ty, "\033]8;;http://example.com\033\\LLLL\033]8;;\033\\");
+ cells = termpty_cellrow_get(&ty, 0, &w);
+ link_id = cells[0].att.link_id;
+ assert(link_id && ty.hl.links[link_id].refcount == 4);
+
+ termpty_resize(&ty, 12, 4);
+ assert(ty.hl.links[link_id].refcount == 4);
+ termpty_resize(&ty, 8, 3);
+ assert(ty.hl.links[link_id].refcount == 4);
+ cells = termpty_cellrow_get(&ty, 0, &w);
+ assert(cells[0].att.link_id == link_id);
+
+ _ty_feed(&ty, "\033c");
+ assert(ty.hl.size == 0 && !ty.hl.links);
+
+ _ty_test_shutdown(&ty);
+ return 0;
+}
+#endif
+
#endif /* BINARY_TYFUZZ || BINARY_TYTEST */
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index f04474ca..daf09b54 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -78,6 +78,7 @@ static struct {
{ "osc8_no_leak", tytest_osc8_no_leak},
{ "links_reset", tytest_links_reset},
{ "resize_wrapped_link", tytest_resize_wrapped_link},
+ { "resize_screen_link_refs", tytest_resize_screen_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 17bf942c..b7c73988 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -51,6 +51,7 @@ int tytest_termpty_read_error(void);
int tytest_osc8_no_leak(void);
int tytest_links_reset(void);
int tytest_resize_wrapped_link(void);
+int tytest_resize_screen_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.