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 d79eac32a27946e1c8033d3fdd200de16e1c0da2
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 20 12:25:13 2026 -0600
tests: add osc8_no_leak to check OSC 8 strings are freed
bef64164 made _handle_esc_osc() free the string it decodes for OSC 8,
but nothing checks it: no escape test sends a hyperlink, and only a
leak checker can see the string go.
osc8_no_leak feeds a hyperlink with an id, a malformed OSC 8 that takes
the early error path, and the closing sequence. Under ASan, without
bef64164, it reports the four decoded strings leaked, 23 bytes.
---
src/bin/termpty.c | 27 +++++++++++++++++++++++++++
src/bin/tytest.c | 1 +
src/bin/unit_tests.h | 1 +
3 files changed, 29 insertions(+)
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index aec6993c..56b39016 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -4630,4 +4630,31 @@ tytest_termpty_read_error(void)
}
#endif
+#if defined(BINARY_TYTEST)
+/* Each OSC 8 frees the string it decodes, valid or not: run under ASan,
+ * a leak fails the test. */
+int
+tytest_osc8_no_leak(void)
+{
+ const Termcell *cells;
+ ssize_t w = 0;
+ uint16_t link_id;
+ Termpty ty;
+
+ _ty_test_init(&ty, 10, 3);
+ _ty_feed(&ty, "\033]8;id=a;http://a\033\\x\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].url &&
+ !strcmp(ty.hl.links[link_id].url, "http://a"));
+ /* parameters with no ';' before the URI */
+ _ty_feed(&ty, "\033]8;id=b\033\\");
+ _ty_feed(&ty, "\033]8;;\033\\");
+
+ _ty_test_shutdown(&ty);
+ 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 a74c2fbb..1ebfaf58 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -75,6 +75,7 @@ static struct {
{ "hl_links_free_full", tytest_hl_links_free_full},
{ "hl_links_exhausted", tytest_hl_links_exhausted},
{ "termpty_read_error", tytest_termpty_read_error},
+ { "osc8_no_leak", tytest_osc8_no_leak},
{ "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 04f5f7e3..7d2bc3ee 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -48,6 +48,7 @@ int tytest_sync_change_cb_altscreen(void);
int tytest_hl_links_free_full(void);
int tytest_hl_links_exhausted(void);
int tytest_termpty_read_error(void);
+int tytest_osc8_no_leak(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.