public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/rubygem-ncursesw] rawhide: Backport upstream patch to migrate to TypedData_Wrap_Struct
Date: Sat, 24 Oct 2026 06:46:24 GMT	[thread overview]
Message-ID: <179282438481.1.476670377365834760.rpms-rubygem-ncursesw-66ed9fce9994@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/rubygem-ncursesw
Branch : rawhide
Commit : 66ed9fce99948d8e05e0400deee06981264fadcf
Author : Mamoru TASAKA <mtasaka@fedoraproject.org>
Date   : 2026-10-24T15:46:09+09:00
Stats  : +261/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/rubygem-ncursesw/c/66ed9fce99948d8e05e0400deee06981264fadcf?branch=rawhide

Log:
Backport upstream patch to migrate to TypedData_Wrap_Struct

---
diff --git a/ncursesw-ecd4c83-migrate-typeddata.patch b/ncursesw-ecd4c83-migrate-typeddata.patch
new file mode 100644
index 0000000..0a21fdd
--- /dev/null
+++ b/ncursesw-ecd4c83-migrate-typeddata.patch
@@ -0,0 +1,253 @@
+From ecd4c8300b813f6dc26c7ffe2ba4b0bbad124415 Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <djc@djc.id.au>
+Date: Sat, 10 Oct 2026 15:26:03 +1100
+Subject: [PATCH] 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 +++++++++++++++------
+ menu_wrap.c    | 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;
+ }
+ 
+diff --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_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) {

diff --git a/rubygem-ncursesw.spec b/rubygem-ncursesw.spec
index 2ea2792..438d88e 100644
--- a/rubygem-ncursesw.spec
+++ b/rubygem-ncursesw.spec
@@ -2,7 +2,7 @@
 
 Name:           rubygem-%{gem_name}
 Version:        1.4.11
-Release:        10%{?dist}
+Release:        11%{?dist}
 Summary:        Ruby wrapper for the ncurses library, with wide character support
 # Automatically converted from old format: LGPLv2+ - review is highly recommended.
 License:        LicenseRef-Callaway-LGPLv2+
@@ -13,6 +13,9 @@ Source0:        https://rubygems.org/gems/%{gem_name}-%{version}.gem
 # https://github.com/sup-heliotrope/ncursesw-ruby/pull/40
 # https://github.com/sup-heliotrope/ncursesw-ruby/commit/bd468ad296ed5bed2e51ad335858e0c92290e492
 Patch0:         %{gem_name}-pr40-c23.patch
+# Migrate to TypedData_Wrap_Struct, needed for ruby4.1
+# https://github.com/sup-heliotrope/ncursesw-ruby/commit/ecd4c8300b813f6dc26c7ffe2ba4b0bbad124415
+Patch1:         %{gem_name}-ecd4c83-migrate-typeddata.patch
 Requires:       ruby
 BuildRequires:  ruby
 BuildRequires:  rubygems-devel
@@ -47,6 +50,7 @@ Documentation for %{name}
 %prep
 %setup -q -n %{gem_name}-%{version}
 %patch -P0 -p1 -b .c23
+%patch -P1 -p1 -b .typed
 
 %build
 # Create the gem as gem install only works on a gem file
@@ -81,6 +85,9 @@ rm -rf %{buildroot}%{gem_instdir}/extconf.rb/
 %{gem_instdir}/examples
 
 %changelog
+* Sat Oct 24 2026 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1.4.11-11
+- Backport upstream patch to migrate to TypedData_Wrap_Struct
+
 * Fri Jul 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.11-10
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
 

                 reply	other threads:[~2026-10-24  6:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179282438481.1.476670377365834760.rpms-rubygem-ncursesw-66ed9fce9994@fedoraproject.org \
    --to=mtasaka@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox