aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-20 21:32:40 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-21 10:23:14 +0900
commitab637cad2b582e8247bafd87a3b0f6323d564f64 (patch)
tree7007be3e1ebaa5cfd1499f3d551f5c53ad72e320 /io.c
parent7ffee5681f85de3fe74c25a90e05e31616113123 (diff)
downloadruby-ab637cad2b582e8247bafd87a3b0f6323d564f64.tar.gz
[Bug #19624] Clean up backquote IO
It should not be hidden, since it can be grabbed by a fiber scheduler.
Diffstat (limited to 'io.c')
-rw-r--r--io.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/io.c b/io.c
index 712dce3ceb..48cdc5b9a7 100644
--- a/io.c
+++ b/io.c
@@ -5574,12 +5574,9 @@ clear_codeconv(rb_io_t *fptr)
clear_writeconv(fptr);
}
-void
-rb_io_fptr_finalize_internal(void *ptr)
+static void
+rb_io_fptr_cleanup_all(rb_io_t *fptr)
{
- rb_io_t *fptr = ptr;
-
- if (!ptr) return;
fptr->pathv = Qnil;
if (0 <= fptr->fd)
rb_io_fptr_cleanup(fptr, TRUE);
@@ -5587,7 +5584,14 @@ rb_io_fptr_finalize_internal(void *ptr)
free_io_buffer(&fptr->rbuf);
free_io_buffer(&fptr->wbuf);
clear_codeconv(fptr);
- free(fptr);
+}
+
+void
+rb_io_fptr_finalize_internal(void *ptr)
+{
+ if (!ptr) return;
+ rb_io_fptr_cleanup_all(ptr);
+ free(ptr);
}
#undef rb_io_fptr_finalize
@@ -10467,11 +10471,9 @@ rb_f_backquote(VALUE obj, VALUE str)
if (NIL_P(port)) return rb_str_new(0,0);
GetOpenFile(port, fptr);
- rb_obj_hide(port);
result = read_all(fptr, remain_size(fptr), Qnil);
rb_io_close(port);
- RFILE(port)->fptr = NULL;
- rb_io_fptr_finalize(fptr);
+ rb_io_fptr_cleanup_all(fptr);
RB_GC_GUARD(port);
return result;