From 0e98508c33f1808d077866bf6d58d871a2781ffa Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 27 Sep 2023 23:25:43 +0900 Subject: [PATCH] string.c (mrb_string_value_cstr): RSTR_PTR(s) may be NULL; fix #6067 --- src/string.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/string.c b/src/string.c index 0adf933c2..bd060a9e4 100644 --- a/src/string.c +++ b/src/string.c @@ -2436,6 +2436,7 @@ mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr) check_null_byte(mrb, ps); p = RSTR_PTR(ps); len = RSTR_LEN(ps); + if (p == NULL) return ""; if (p[len] == '\0') { return p; }