Fix `fptr` leakage; ref #3903

parent 83d02bcd
......@@ -566,6 +566,9 @@ mrb_io_initialize_copy(mrb_state *mrb, mrb_value copy)
fptr_copy = (struct mrb_io *)mrb_io_alloc(mrb);
fptr_orig = io_get_open_fptr(mrb, orig);
DATA_TYPE(copy) = &mrb_io_type;
DATA_PTR(copy) = fptr_copy;
buf = mrb_iv_get(mrb, orig, mrb_intern_cstr(mrb, "@buf"));
mrb_iv_set(mrb, copy, mrb_intern_cstr(mrb, "@buf"), buf);
......@@ -577,9 +580,6 @@ mrb_io_initialize_copy(mrb_state *mrb, mrb_value copy)
fptr_copy->sync = fptr_orig->sync;
fptr_copy->is_socket = fptr_orig->is_socket;
DATA_TYPE(copy) = &mrb_io_type;
DATA_PTR(copy) = fptr_copy;
return copy;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment