From: Dan Callaghan <dan@bl2.djc.id.au>
To: sup-commits@supmua.dev
Subject: [ncursesw-ruby.git] 04/10: fix missing NULL checks for return values
Date: Sat, 17 Oct 2026 11:25:02 +1100 [thread overview]
Message-ID: <20261017002459.0699D29BBCD@bl2.djc.id.au> (raw)
In-Reply-To: <179219669847.381480.6906705364727468632@bl2.djc.id.au>
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)
next prev parent reply other threads:[~2026-10-17 0:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Dan Callaghan [this message]
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
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=20261017002459.0699D29BBCD@bl2.djc.id.au \
--to=dan@bl2.djc.id.au \
--cc=djc@djc.id.au \
--cc=sup-commits@supmua.dev \
/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