* [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c)
@ 2026-10-17 0:24 Dan Callaghan
2026-10-17 0:24 ` [ncursesw-ruby.git] 01/10: fix segfault when tigetstr() returns -1 Dan Callaghan
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:24 UTC (permalink / raw)
To: sup-commits
Pushed branch master:
from de96552 release 1.4.13
new b813258 fix segfault when tigetstr() returns -1
new b760630 fix wrong argument passed to wenclose()
new 4e4c03b fix wrong argument handling in mvwgetch()
new 4f55077 fix missing NULL checks for return values
new ecd4c83 migrate to TypedData_Wrap_Struct() and family
new 412d8fc add GC mark function for PANEL to mark userptr
new 63c77b2 fix add_wch()
new ab7ef74 fix duplicate definition of pair_content method
new 07ac8c9 ensure definitions are only done once
new 4bf538c fix copy-paste mistake in name of FIELDTYPE wrapper
Summary of changes:
form_wrap.c | 29 +++++++++++++++++++++--------
menu_wrap.c | 18 +++++++++++++-----
ncurses_wrap.c | 52 ++++++++++++++++++++++++++++++++++++----------------
panel_wrap.c | 12 ++++++++++--
4 files changed, 80 insertions(+), 31 deletions(-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 01/10: fix segfault when tigetstr() returns -1
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
@ 2026-10-17 0:24 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 02/10: fix wrong argument passed to wenclose() Dan Callaghan
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:24 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/b8132587a1c0649b49fdbb597a4d98b44741d46d.html
commit b8132587a1c0649b49fdbb597a4d98b44741d46d
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Mon Oct 5 19:51:03 2026 +1100
fix segfault when tigetstr() returns -1
---
ncurses_wrap.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index c3efd9f..7f7ef89 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -1495,7 +1495,9 @@ static VALUE rbncurs_tigetnum(VALUE dummy, VALUE arg1) {
#endif
#ifdef HAVE_TIGETSTR
static VALUE rbncurs_tigetstr(VALUE dummy, VALUE arg1) {
- return rb_str_new2(tigetstr(STR2CSTR(arg1)));
+ char * str = tigetstr(STR2CSTR(arg1));
+ if (str == NULL || str == (char *)-1) return Qnil;
+ return rb_str_new2(str);
}
#endif
static VALUE rbncurs_timeout(VALUE dummy, VALUE arg1) {
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 02/10: fix wrong argument passed to wenclose()
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
2026-10-17 0:24 ` [ncursesw-ruby.git] 01/10: fix segfault when tigetstr() returns -1 Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 03/10: fix wrong argument handling in mvwgetch() Dan Callaghan
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/b760630f6ccbfa3c14ed552b6913b179475dc402.html
commit b760630f6ccbfa3c14ed552b6913b179475dc402
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Thu Oct 8 21:06:19 2026 +1100
fix wrong argument passed to wenclose()
---
ncurses_wrap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index 7f7ef89..e511a4e 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -2377,7 +2377,7 @@ static VALUE rbncurs_mousemask(VALUE dummy, VALUE rb_newmask, VALUE rb_oldmask)
#ifdef HAVE_WENCLOSE
static VALUE rbncurs_wenclose(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x)
{
- return wenclose(get_window(rb_win), NUM2INT(rb_y), NUM2INT(rb_y))
+ return wenclose(get_window(rb_win), NUM2INT(rb_y), NUM2INT(rb_x))
? Qtrue : Qfalse;
}
#endif
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 03/10: fix wrong argument handling in mvwgetch()
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
2026-10-17 0:24 ` [ncursesw-ruby.git] 01/10: fix segfault when tigetstr() returns -1 Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 02/10: fix wrong argument passed to wenclose() Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 04/10: fix missing NULL checks for return values Dan Callaghan
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/4e4c03b8b720253a90fb6298a8b7857571f8c60d.html
commit 4e4c03b8b720253a90fb6298a8b7857571f8c60d
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Thu Oct 8 21:16:08 2026 +1100
fix wrong argument handling in mvwgetch()
---
ncurses_wrap.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index e511a4e..7325390 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -1246,10 +1246,10 @@ static VALUE rbncurs_mvwchgat(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3, V
static VALUE rbncurs_mvwdelch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
return INT2NUM(mvwdelch(get_window(arg1), NUM2INT(arg2), NUM2INT(arg3)));
}
-static VALUE rbncurs_mvwgetch(VALUE dummy, VALUE arg1, VALUE arg2, VALUE arg3) {
- WINDOW * c_win = get_window(arg1);
- int windelay = NUM2INT(rb_iv_get(arg1, "@timeout"));
- if (wmove(c_win, NUM2INT(arg1), NUM2INT(arg2)) == ERR)
+static VALUE rbncurs_mvwgetch(VALUE dummy, VALUE rb_win, VALUE rb_y, VALUE rb_x) {
+ WINDOW * c_win = get_window(rb_win);
+ int windelay = NUM2INT(rb_iv_get(rb_win, "@timeout"));
+ if (wmove(c_win, NUM2INT(rb_y), NUM2INT(rb_x)) == ERR)
return INT2NUM(ERR);
return INT2NUM(rbncurshelper_nonblocking_wgetch(c_win, windelay));
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 04/10: fix missing NULL checks for return values
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
` (2 preceding siblings ...)
2026-10-17 0:25 ` [ncursesw-ruby.git] 03/10: fix wrong argument handling in mvwgetch() Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 05/10: migrate to TypedData_Wrap_Struct() and family Dan Callaghan
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/4f55077757cf64d7d402983d05964e2a98a6499c.html
commit 4f55077757cf64d7d402983d05964e2a98a6499c
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Thu Oct 8 21:29:38 2026 +1100
fix missing NULL checks for return values
---
form_wrap.c | 8 ++++++--
| 4 +++-
ncurses_wrap.c | 14 +++++++++++---
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/form_wrap.c b/form_wrap.c
index be7c232..8a3a837 100644
--- a/form_wrap.c
+++ b/form_wrap.c
@@ -763,7 +763,9 @@ static VALUE rbncurs_m_set_field_buffer(VALUE dummy, VALUE rb_field, VALUE buf,
static VALUE rbncurs_c_field_buffer(VALUE rb_field, VALUE buffer) {
FIELD* field = get_field(rb_field);
- return rb_str_new2(field_buffer(field, NUM2INT(buffer)));
+ char * str = field_buffer(field, NUM2INT(buffer));
+ if (str == NULL) return Qnil;
+ return rb_str_new2(str);
}
static VALUE rbncurs_m_field_buffer(VALUE dummy, VALUE rb_field, VALUE buffer)
{ return rbncurs_c_field_buffer(rb_field, buffer); }
@@ -1060,7 +1062,9 @@ static VALUE rbncurs_m_form_opts(VALUE dummy, VALUE rb_form)
* form_requestname
*/
static VALUE rbncurs_c_form_request_name(VALUE request) {
- return rb_str_new2(form_request_name(NUM2INT(request)));
+ char * str = form_request_name(NUM2INT(request));
+ if (str == NULL) return Qnil;
+ return rb_str_new2(str);
}
static VALUE rbncurs_m_form_request_name(VALUE dummy, VALUE request)
{ return rbncurs_c_form_request_name(request); }
--git a/menu_wrap.c b/menu_wrap.c
index 16b52d8..0578d77 100644
--- a/menu_wrap.c
+++ b/menu_wrap.c
@@ -664,7 +664,9 @@ static VALUE rbncurs_m_menu_opts(VALUE dummy, VALUE rb_menu)
*/
static VALUE rbncurs_c_menu_request_name(VALUE request)
{
- return rb_str_new2(menu_request_name(NUM2INT(request)));
+ char *str = menu_request_name(NUM2INT(request));
+ if (str == NULL) return Qnil;
+ return rb_str_new2(str);
}
static VALUE rbncurs_m_menu_request_name(VALUE dummy, VALUE request)
{ return rbncurs_c_menu_request_name(request); }
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index 7325390..6adbc3b 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -1126,7 +1126,9 @@ static VALUE rbncurs_is_wintouched(VALUE dummy, VALUE arg1) {
return (is_wintouched(get_window(arg1))) ? Qtrue : Qfalse;
}
static VALUE rbncurs_keyname(VALUE dummy, VALUE arg1) {
- return rb_str_new2(keyname(NUM2INT(arg1)));
+ const char * str = keyname(NUM2INT(arg1));
+ if (str == NULL) return Qnil;
+ return rb_str_new2(str);
}
static VALUE rbncurs_keypad(VALUE dummy, VALUE arg1, VALUE arg2) {
return INT2NUM(keypad(get_window(arg1), RTEST(arg2)));
@@ -1442,7 +1444,9 @@ static VALUE rbncurs_slk_init(VALUE dummy, VALUE arg1) {
return INT2NUM(slk_init(NUM2INT(arg1)));
}
static VALUE rbncurs_slk_label(VALUE dummy, VALUE arg1) {
- return rb_str_new2(slk_label(NUM2INT(arg1)));
+ char * str = slk_label(NUM2INT(arg1));
+ if (str == NULL) return Qnil;
+ return rb_str_new2(str);
}
static VALUE rbncurs_slk_noutrefresh(VALUE dummy) {
return INT2NUM(slk_noutrefresh());
@@ -2839,7 +2843,11 @@ void init_SCREEN_methods(void)
#ifdef HAVE_LOCALE_H
static VALUE rbncurs_setlocale(VALUE dummy, VALUE category, VALUE locale)
-{ return rb_str_new2(setlocale(NUM2INT(category), STR2CSTR(locale)));}
+{
+ char * str = setlocale(NUM2INT(category), STR2CSTR(locale));
+ if (str == NULL) return Qnil;
+ return rb_str_new2(str);
+}
#endif
static void init_safe_functions(void)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 05/10: migrate to TypedData_Wrap_Struct() and family
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
` (3 preceding siblings ...)
2026-10-17 0:25 ` [ncursesw-ruby.git] 04/10: fix missing NULL checks for return values Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 06/10: add GC mark function for PANEL to mark userptr Dan Callaghan
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/ecd4c8300b813f6dc26c7ffe2ba4b0bbad124415.html
commit ecd4c8300b813f6dc26c7ffe2ba4b0bbad124415
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Oct 10 15:26:03 2026 +1100
migrate to TypedData_Wrap_Struct() and family
This provides type checking before dereferencing the wrapped pointers
passed back from Ruby, avoiding potential segfaults due to memory
reinterpretation.
---
form_wrap.c | 21 +++++++++++++++------
| 14 ++++++++++----
ncurses_wrap.c | 14 ++++++++++----
panel_wrap.c | 7 +++++--
4 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/form_wrap.c b/form_wrap.c
index 8a3a837..2399e37 100644
--- a/form_wrap.c
+++ b/form_wrap.c
@@ -253,6 +253,9 @@ void init_form_opts_constants() {
/*
* FIELD wrapper
*/
+static const struct rb_data_type_struct field_rbtype = {
+ .wrap_struct_name = "Ncurses::Form::FIELDTYPE",
+};
static VALUE wrap_field(FIELD* field)
{
if (field == 0) return Qnil;
@@ -261,7 +264,7 @@ static VALUE wrap_field(FIELD* field)
VALUE field_adress = INT2NUM((long)(field));
VALUE rb_field = rb_hash_aref(fields_hash, field_adress);
if (rb_field == Qnil) {
- rb_field = Data_Wrap_Struct(cFIELD, 0, 0, field);
+ rb_field = TypedData_Wrap_Struct(cFIELD, &field_rbtype, field);
rb_iv_set(rb_field, "@destroyed", Qfalse);
rb_hash_aset(fields_hash, field_adress, rb_field);
}
@@ -276,13 +279,16 @@ static FIELD* get_field(VALUE rb_field)
rb_raise(rb_eRuntimeError, "Attempt to access a destroyed field");
return 0;
}
- Data_Get_Struct(rb_field, FIELD, field);
+ TypedData_Get_Struct(rb_field, FIELD, &field_rbtype, field);
return field;
}
/*
* FIELDTYPE wrapper
*/
+static const struct rb_data_type_struct fieldtype_rbtype = {
+ .wrap_struct_name = "Ncurses::Form::FIELD",
+};
static VALUE wrap_fieldtype(FIELDTYPE* fieldtype)
{
if (fieldtype == NULL) return Qnil;
@@ -291,7 +297,7 @@ static VALUE wrap_fieldtype(FIELDTYPE* fieldtype)
VALUE fieldtype_adress = INT2NUM((long)(fieldtype));
VALUE rb_fieldtype = rb_hash_aref(fieldtypes_hash, fieldtype_adress);
if (rb_fieldtype == Qnil) {
- rb_fieldtype = Data_Wrap_Struct(cFIELDTYPE, 0, 0, fieldtype);
+ rb_fieldtype = TypedData_Wrap_Struct(cFIELDTYPE, &fieldtype_rbtype, fieldtype);
rb_iv_set(rb_fieldtype, "@destroyed", Qfalse);
rb_hash_aset(fieldtypes_hash, fieldtype_adress, rb_fieldtype);
}
@@ -306,13 +312,16 @@ static FIELDTYPE* get_fieldtype(VALUE rb_fieldtype)
rb_raise(rb_eRuntimeError, "Attempt to access a destroyed fieldtype");
return 0;
}
- Data_Get_Struct(rb_fieldtype, FIELDTYPE, fieldtype);
+ TypedData_Get_Struct(rb_fieldtype, FIELDTYPE, &fieldtype_rbtype, fieldtype);
return fieldtype;
}
/*
* FORM wrapper
*/
+static const struct rb_data_type_struct form_rbtype = {
+ .wrap_struct_name = "Ncurses::Form::FORM",
+};
static VALUE wrap_form(FORM* form)
{
if (form == 0) return Qnil;
@@ -321,7 +330,7 @@ static VALUE wrap_form(FORM* form)
VALUE form_adress = INT2NUM((long)(form));
VALUE rb_form = rb_hash_aref(forms_hash, form_adress);
if (rb_form == Qnil) {
- rb_form = Data_Wrap_Struct(cFORM, 0, 0, form);
+ rb_form = TypedData_Wrap_Struct(cFORM, &form_rbtype, form);
rb_iv_set(rb_form, "@destroyed", Qfalse);
rb_hash_aset(forms_hash, form_adress, rb_form);
}
@@ -336,7 +345,7 @@ static FORM* get_form(VALUE rb_form)
rb_raise(rb_eRuntimeError, "Attempt to access a destroyed form");
return 0;
}
- Data_Get_Struct(rb_form, FORM, form);
+ TypedData_Get_Struct(rb_form, FORM, &form_rbtype, form);
return form;
}
--git a/menu_wrap.c b/menu_wrap.c
index 0578d77..7c6a8ea 100644
--- a/menu_wrap.c
+++ b/menu_wrap.c
@@ -140,6 +140,9 @@ void init_menu_opts_constants(void)
/*
* ITEM wrapper
*/
+static const struct rb_data_type_struct item_rbtype = {
+ .wrap_struct_name = "Ncurses::Menu::ITEM",
+};
static VALUE wrap_item(ITEM *item)
{
if (item == 0) return Qnil;
@@ -150,7 +153,7 @@ static VALUE wrap_item(ITEM *item)
if (rb_item == Qnil)
{
- rb_item = Data_Wrap_Struct(cITEM, 0, 0, item);
+ rb_item = TypedData_Wrap_Struct(cITEM, &item_rbtype, item);
rb_iv_set(rb_item, "@destroyed", Qfalse);
rb_hash_aset(items_hash, item_address, rb_item);
}
@@ -167,7 +170,7 @@ static ITEM *get_item(VALUE rb_item)
rb_raise(rb_eRuntimeError, "Attempt to access a destroyed item");
return 0;
}
- Data_Get_Struct(rb_item, ITEM, item);
+ TypedData_Get_Struct(rb_item, ITEM, &item_rbtype, item);
return item;
}
@@ -175,6 +178,9 @@ static ITEM *get_item(VALUE rb_item)
/*
* MENU wrapper
*/
+static const struct rb_data_type_struct menu_rbtype = {
+ .wrap_struct_name = "Ncurses::Menu::MENU",
+};
static VALUE wrap_menu(MENU *menu)
{
if (menu == 0) return Qnil;
@@ -185,7 +191,7 @@ static VALUE wrap_menu(MENU *menu)
if (rb_menu == Qnil)
{
- rb_menu = Data_Wrap_Struct(cMENU, 0, 0, menu);
+ rb_menu = TypedData_Wrap_Struct(cMENU, &menu_rbtype, menu);
rb_iv_set(rb_menu, "@destroyed", Qfalse);
rb_hash_aset(menus_hash, menu_address, rb_menu);
}
@@ -202,7 +208,7 @@ static MENU *get_menu(VALUE rb_menu)
rb_raise(rb_eRuntimeError, "Attempt to access a destroyed menu");
return 0;
}
- Data_Get_Struct(rb_menu, MENU, menu);
+ TypedData_Get_Struct(rb_menu, MENU, &menu_rbtype, menu);
return menu;
}
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index 6adbc3b..eb0a9b7 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -223,6 +223,9 @@ long rbncurs_array_length(VALUE array)
return NUM2LONG(rb_funcall(array, rb_intern("length"), 0));
}
+static const struct rb_data_type_struct window_rbtype = {
+ .wrap_struct_name = "Ncurses::WINDOW",
+};
VALUE wrap_window(WINDOW* window)
{
if (window == 0) return Qnil;
@@ -231,7 +234,7 @@ VALUE wrap_window(WINDOW* window)
VALUE window_adress = INT2NUM((long)(window));
VALUE rb_window = rb_hash_aref(windows_hash, window_adress);
if (rb_window == Qnil) {
- rb_window = Data_Wrap_Struct(cWINDOW, 0, 0, window);
+ rb_window = TypedData_Wrap_Struct(cWINDOW, &window_rbtype, window);
rb_iv_set(rb_window, "@destroyed", Qfalse);
rb_iv_set(rb_window, "@timeout", INT2FIX(-1));
rb_hash_aset(windows_hash, window_adress, rb_window);
@@ -247,7 +250,7 @@ WINDOW* get_window(VALUE rb_window)
rb_raise(eNcurses, "Attempt to access a destroyed window");
return 0;
}
- Data_Get_Struct(rb_window, WINDOW, window);
+ TypedData_Get_Struct(rb_window, WINDOW, &window_rbtype, window);
return window;
}
static VALUE rbncurs_delwin(VALUE dummy, VALUE arg1) {
@@ -259,6 +262,9 @@ static VALUE rbncurs_delwin(VALUE dummy, VALUE arg1) {
return INT2NUM(delwin(window));
}
+static const struct rb_data_type_struct screen_rbtype = {
+ .wrap_struct_name = "Ncurses::SCREEN",
+};
static VALUE wrap_screen(SCREEN* screen)
{
if (screen == 0) return Qnil;
@@ -267,7 +273,7 @@ static VALUE wrap_screen(SCREEN* screen)
VALUE screen_adress = INT2NUM((long)(screen));
VALUE rb_screen = rb_hash_aref(screens_hash, screen_adress);
if (rb_screen == Qnil) {
- rb_screen = Data_Wrap_Struct(cSCREEN, 0, 0, screen);
+ rb_screen = TypedData_Wrap_Struct(cSCREEN, &screen_rbtype, screen);
rb_iv_set(rb_screen, "@destroyed", Qfalse);
rb_hash_aset(screens_hash, screen_adress, rb_screen);
}
@@ -282,7 +288,7 @@ static SCREEN* get_screen(VALUE rb_screen)
rb_raise(eNcurses, "Attempt to access a destroyed screen");
return 0;
}
- Data_Get_Struct(rb_screen, SCREEN, screen);
+ TypedData_Get_Struct(rb_screen, SCREEN, &screen_rbtype, screen);
return screen;
}
#ifdef HAVE_DELSCREEN
diff --git a/panel_wrap.c b/panel_wrap.c
index b9d67a7..6cf350b 100644
--- a/panel_wrap.c
+++ b/panel_wrap.c
@@ -29,6 +29,9 @@
VALUE mPanel;
VALUE cPANEL;
+static const struct rb_data_type_struct panel_rbtype = {
+ .wrap_struct_name = "Ncurses::Panel::PANEL",
+};
static VALUE wrap_panel(PANEL* panel)
{
if (panel == 0) return Qnil;
@@ -37,7 +40,7 @@ static VALUE wrap_panel(PANEL* panel)
VALUE panel_adress = INT2NUM((long)(panel));
VALUE rb_panel = rb_hash_aref(panels_hash, panel_adress);
if (rb_panel == Qnil) {
- rb_panel = Data_Wrap_Struct(cPANEL, 0, 0, panel);
+ rb_panel = TypedData_Wrap_Struct(cPANEL, &panel_rbtype, panel);
rb_iv_set(rb_panel, "@destroyed", Qfalse);
rb_hash_aset(panels_hash, panel_adress, rb_panel);
}
@@ -52,7 +55,7 @@ static PANEL* get_panel(VALUE rb_panel)
rb_raise(rb_eRuntimeError, "Attempt to access a destroyed panel");
return 0;
}
- Data_Get_Struct(rb_panel, PANEL, panel);
+ TypedData_Get_Struct(rb_panel, PANEL, &panel_rbtype, panel);
return panel;
}
static VALUE rbncurs_c_del_panel(VALUE rb_panel) {
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 06/10: add GC mark function for PANEL to mark userptr
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
` (4 preceding siblings ...)
2026-10-17 0:25 ` [ncursesw-ruby.git] 05/10: migrate to TypedData_Wrap_Struct() and family Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 07/10: fix add_wch() Dan Callaghan
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/412d8fc2a66d20da280daa2536dd53d57d1232fe.html
commit 412d8fc2a66d20da280daa2536dd53d57d1232fe
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Oct 10 16:04:52 2026 +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.
---
panel_wrap.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/panel_wrap.c b/panel_wrap.c
index 6cf350b..b702c52 100644
--- 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)
{
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 07/10: fix add_wch()
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
` (5 preceding siblings ...)
2026-10-17 0:25 ` [ncursesw-ruby.git] 06/10: add GC mark function for PANEL to mark userptr Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 08/10: fix duplicate definition of pair_content method Dan Callaghan
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/63c77b2506f6bb994f15f6bd5db25beb4754e747.html
commit 63c77b2506f6bb994f15f6bd5db25beb4754e747
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Oct 10 16:09:26 2026 +1100
fix add_wch()
Make it construct an actual cchar_t value like wadd_wch() already does,
rather than wrongly casting a wchar_t.
---
ncurses_wrap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index eb0a9b7..2b3f371 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -586,8 +586,8 @@ static VALUE rbncurs_addch(VALUE dummy, VALUE arg1) {
}
#ifdef HAVE_ADD_WCH
static VALUE rbncurs_add_wch(VALUE dummy, VALUE arg1) {
- wchar_t c = NUM2ULONG(arg1);
- return INT2NUM(add_wch((cchar_t *)&c));
+ cchar_t c = { 0, { NUM2ULONG(arg1), 0 } };
+ return INT2NUM(add_wch(&c));
}
#endif
static VALUE rbncurs_addchnstr(VALUE dummy, VALUE arg1, VALUE arg2) {
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 08/10: fix duplicate definition of pair_content method
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
` (6 preceding siblings ...)
2026-10-17 0:25 ` [ncursesw-ruby.git] 07/10: fix add_wch() Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 09/10: ensure definitions are only done once Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 10/10: fix copy-paste mistake in name of FIELDTYPE wrapper Dan Callaghan
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/ab7ef7466ce78093d4c97ae014c3d345dc71ac99.html
commit ab7ef7466ce78093d4c97ae014c3d345dc71ac99
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Oct 10 18:10:30 2026 +1100
fix duplicate definition of pair_content method
It was causing a warning in Sup's test suite, now that there is a call
to Ncurses.newterm:
test/unit/test_line_cursor_mode.rb:15: warning: method redefined; discarding old pair_content
---
ncurses_wrap.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index 2b3f371..8ef2d2e 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -2090,7 +2090,6 @@ static void init_functions_2(void) {
NCFUNC(wvline, 3);
NCFUNC(color_content, 4);
NCFUNC(pair_content, 3);
- NCFUNC(pair_content, 3);
#ifdef HAVE_GETWIN
NCFUNC(getwin, 1);
#endif
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 09/10: ensure definitions are only done once
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
` (7 preceding siblings ...)
2026-10-17 0:25 ` [ncursesw-ruby.git] 08/10: fix duplicate definition of pair_content method Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 10/10: fix copy-paste mistake in name of FIELDTYPE wrapper Dan Callaghan
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/07ac8c9b0b9c31b91e6c5192efdd79e96733a394.html
commit 07ac8c9b0b9c31b91e6c5192efdd79e96733a394
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sat Oct 10 18:12:30 2026 +1100
ensure definitions are only done once
Init_ncurses_full() is called from a number of places, which may happen
multiple times after the module is initially require'd. In this case it
would produce a huge number of "method redefined" warnings, for example
in Sup's test suite now that there is a call to Ncurses.new_term.
---
ncurses_wrap.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ncurses_wrap.c b/ncurses_wrap.c
index 8ef2d2e..0773bc0 100644
--- a/ncurses_wrap.c
+++ b/ncurses_wrap.c
@@ -2896,6 +2896,9 @@ void Init_ncursesw_bin(void)
}
static void Init_ncurses_full(void)
{
+ static bool already_done = false;
+ if (already_done) return;
+
init_globals_1();
init_globals_2();
init_functions_0();
@@ -2913,4 +2916,6 @@ static void Init_ncurses_full(void)
#if defined(HAVE_MENU_H) || defined(HAVE_NCURSESW_MENU_H)
init_menu();
#endif
+
+ already_done = true;
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [ncursesw-ruby.git] 10/10: fix copy-paste mistake in name of FIELDTYPE wrapper
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
` (8 preceding siblings ...)
2026-10-17 0:25 ` [ncursesw-ruby.git] 09/10: ensure definitions are only done once Dan Callaghan
@ 2026-10-17 0:25 ` Dan Callaghan
9 siblings, 0 replies; 11+ messages in thread
From: Dan Callaghan @ 2026-10-17 0:25 UTC (permalink / raw)
To: sup-commits
New commit on branch master:
https://supmua.dev/git/ncursesw-ruby/commit/4bf538c8e38b170327f9ec9fc54f4cd99e83bf73.html
commit 4bf538c8e38b170327f9ec9fc54f4cd99e83bf73
Author: Dan Callaghan <djc@djc.id.au>
AuthorDate: Sun Oct 11 19:27:19 2026 +1100
fix copy-paste mistake in name of FIELDTYPE wrapper
---
form_wrap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/form_wrap.c b/form_wrap.c
index 2399e37..f3a283b 100644
--- a/form_wrap.c
+++ b/form_wrap.c
@@ -287,7 +287,7 @@ static FIELD* get_field(VALUE rb_field)
* FIELDTYPE wrapper
*/
static const struct rb_data_type_struct fieldtype_rbtype = {
- .wrap_struct_name = "Ncurses::Form::FIELD",
+ .wrap_struct_name = "Ncurses::Form::FIELDTYPE",
};
static VALUE wrap_fieldtype(FIELDTYPE* fieldtype)
{
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-10-17 0:24 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-17 0:24 [ncursesw-ruby.git] branch master updated (de96552 -> 4bf538c) Dan Callaghan
2026-10-17 0:24 ` [ncursesw-ruby.git] 01/10: fix segfault when tigetstr() returns -1 Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 02/10: fix wrong argument passed to wenclose() Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 03/10: fix wrong argument handling in mvwgetch() Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 04/10: fix missing NULL checks for return values Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 05/10: migrate to TypedData_Wrap_Struct() and family Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 06/10: add GC mark function for PANEL to mark userptr Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 07/10: fix add_wch() Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 08/10: fix duplicate definition of pair_content method Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 09/10: ensure definitions are only done once Dan Callaghan
2026-10-17 0:25 ` [ncursesw-ruby.git] 10/10: fix copy-paste mistake in name of FIELDTYPE wrapper Dan Callaghan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox