string.c (mrb_string_value_cstr): RSTR_PTR(s) may be NULL; fix #6067

This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-09-27 23:25:43 +09:00
parent 4c7fab6126
commit 0e98508c33
+1
View File
@@ -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;
}