sup

A curses threads-with-tags style email client

ncursesw-ruby.git

git clone https://supmua.dev/git/ncursesw-ruby/
commit 412d8fc2a66d20da280daa2536dd53d57d1232fe
parent ecd4c8300b813f6dc26c7ffe2ba4b0bbad124415
Author: Dan Callaghan <djc@djc.id.au>
Date:   Sat, 10 Oct 2026 16:04:52 +1100

add GC mark function for PANEL to mark userptr

Otherwise a Ruby object saved in userptr may be garbage collected while
it is still referenced by the PANEL, resulting in a user-after-free.

Diffstat:
M panel_wrap.c | 5 +++++
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/panel_wrap.c b/panel_wrap.c
@@ -29,8 +29,13 @@
 VALUE mPanel;
 VALUE cPANEL;
 
+static void panel_rb_mark(void * panel) {
+    const void * userptr = panel_userptr((PANEL*)panel);
+    if (userptr != NULL) rb_gc_mark((VALUE)userptr);
+}
 static const struct rb_data_type_struct panel_rbtype = {
     .wrap_struct_name = "Ncurses::Panel::PANEL",
+    .function.dmark = panel_rb_mark,
 };
 static VALUE wrap_panel(PANEL* panel)
 {