aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-15 14:19:54 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-15 22:53:08 +1200
commita9b2a96c5cfa5ab36c89ffae82e28eb733e36542 (patch)
treef74064a5819affdff30a9309910e69b41e7b8a5d /io.c
parentb2b855f486dd0b1b11baaea4943116a9d2d7e867 (diff)
downloadruby-a9b2a96c5cfa5ab36c89ffae82e28eb733e36542.tar.gz
Fix incorrect initialization of `rb_io_t::self`.
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/io.c b/io.c
index ed808d071c..e5fac3c18c 100644
--- a/io.c
+++ b/io.c
@@ -8214,6 +8214,7 @@ prep_io(int fd, int fmode, VALUE klass, const char *path)
VALUE io = io_alloc(klass);
MakeOpenFile(io, fp);
+ fp->self = io;
fp->fd = fd;
fp->mode = fmode;
if (!io_check_tty(fp)) {
@@ -8297,6 +8298,7 @@ static inline rb_io_t *
rb_io_fptr_new(void)
{
rb_io_t *fp = ALLOC(rb_io_t);
+ fp->self = Qnil;
fp->fd = -1;
fp->stdio_file = NULL;
fp->mode = 0;
@@ -8329,11 +8331,12 @@ rb_io_make_open_file(VALUE obj)
Check_Type(obj, T_FILE);
if (RFILE(obj)->fptr) {
- rb_io_close(obj);
- rb_io_fptr_finalize(RFILE(obj)->fptr);
- RFILE(obj)->fptr = 0;
+ rb_io_close(obj);
+ rb_io_fptr_finalize(RFILE(obj)->fptr);
+ RFILE(obj)->fptr = 0;
}
fp = rb_io_fptr_new();
+ fp->self = obj;
RFILE(obj)->fptr = fp;
return fp;
}