From 940a042e1670bfcb0a56c87c0eefd2b89191ab4e Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 21 Nov 2023 12:59:06 +1300 Subject: [PATCH] Don't update `io` which is subsequently stored. Retain the original. (#306) --- ext/nio4r/monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/nio4r/monitor.c b/ext/nio4r/monitor.c index a8a8cfc..41f81be 100644 --- a/ext/nio4r/monitor.c +++ b/ext/nio4r/monitor.c @@ -108,8 +108,8 @@ static VALUE NIO_Monitor_initialize(VALUE self, VALUE io, VALUE interests, VALUE rb_raise(rb_eArgError, "invalid event type %s (must be :r, :w, or :rw)", RSTRING_PTR(rb_funcall(interests, rb_intern("inspect"), 0))); } - io = rb_convert_type(io, T_FILE, "IO", "to_io"); - ev_io_init(&monitor->ev_io, NIO_Selector_monitor_callback, rb_io_descriptor(io), monitor->interests); + int descriptor = rb_io_descriptor(rb_convert_type(io, T_FILE, "IO", "to_io")); + ev_io_init(&monitor->ev_io, NIO_Selector_monitor_callback, descriptor, monitor->interests); rb_ivar_set(self, rb_intern("io"), io); rb_ivar_set(self, rb_intern("interests"), interests);