summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2020-12-02 09:42:05 +0900
committerKenta Murata <mrkn@mrkn.jp>2020-12-02 09:44:03 +0900
commit82dc0c6aa380ea736adcd5ea54ec8f77a9269007 (patch)
tree5b7e1f3501299bc2a83c5a0459ebfd56856f71b9 /ext
parent7172272c4ca290b0b8d5bed4dd9de84eb1561303 (diff)
memory_view.c: Check availability in rb_memory_view_get
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/memory_view/memory_view.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/-test-/memory_view/memory_view.c b/ext/-test-/memory_view/memory_view.c
index 7f1f007..f7c5090 100644
--- a/ext/-test-/memory_view/memory_view.c
+++ b/ext/-test-/memory_view/memory_view.c
@@ -35,7 +35,8 @@ exportable_string_get_memory_view(VALUE obj, rb_memory_view_t *view, int flags)
static int
exportable_string_memory_view_available_p(VALUE obj)
{
- return Qtrue;
+ VALUE str = rb_ivar_get(obj, id_str);
+ return !NIL_P(str);
}
static const rb_memory_view_entry_t exportable_string_memory_view_entry = {
@@ -232,6 +233,9 @@ memory_view_ref_count_while_exporting(VALUE mod, VALUE obj, VALUE n)
static VALUE
expstr_initialize(VALUE obj, VALUE s)
{
+ if (!NIL_P(s)) {
+ Check_Type(s, T_STRING);
+ }
rb_ivar_set(obj, id_str, s);
return Qnil;
}