From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by bl2.djc.id.au (Postfix, from userid 1000) id 0699D29BBCD; Sat, 17 Oct 2026 11:24:59 +1100 (AEDT) Date: Sat, 17 Oct 2026 11:25:02 +1100 To: sup-commits@supmua.dev Subject: [ncursesw-ruby.git] 04/10: fix missing NULL checks for return values MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Reply-To: Dan Callaghan In-Reply-To: <179219669847.381480.6906705364727468632@bl2.djc.id.au> References: <179219669847.381480.6906705364727468632@bl2.djc.id.au> Thread-Index: AQAAEjRW1ch74naHRnKg4xL7js+6AQ== X-Git-Host: bl2.djc.id.au X-Git-Repo: ncursesw-ruby.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 4f55077757cf64d7d402983d05964e2a98a6499c X-Git-NotificationType: diff X-Git-Multimail-Version: 1.7.dev Auto-Submitted: auto-generated Message-Id: <20261017002459.0699D29BBCD@bl2.djc.id.au> From: Dan Callaghan List-Id: New commit on branch master: https://supmua.dev/git/ncursesw-ruby/commit/4f55077757cf64d7d402983d05964e2a98a6499c.html commit 4f55077757cf64d7d402983d05964e2a98a6499c Author: Dan Callaghan AuthorDate: Thu Oct 8 21:29:38 2026 +1100 fix missing NULL checks for return values --- form_wrap.c | 8 ++++++-- menu_wrap.c | 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); } diff --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)