@@ -2569,7 +2569,9 @@ rb_io_buffer_initialize_copy(VALUE self, VALUE source)
25692569
25702570 io_buffer_initialize (self , buffer , NULL , source_size , io_flags_for_size (source_size ), Qnil );
25712571
2572- return io_buffer_copy_from (buffer , source_base , source_size , 0 , NULL );
2572+ VALUE result = io_buffer_copy_from (buffer , source_base , source_size , 0 , NULL );
2573+ RB_GC_GUARD (source );
2574+ return result ;
25732575}
25742576
25752577/*
@@ -2654,7 +2656,9 @@ io_buffer_copy(int argc, VALUE *argv, VALUE self)
26542656
26552657 rb_io_buffer_get_bytes_for_reading (source , & source_base , & source_size );
26562658
2657- return io_buffer_copy_from (buffer , source_base , source_size , argc - 1 , argv + 1 );
2659+ VALUE result = io_buffer_copy_from (buffer , source_base , source_size , argc - 1 , argv + 1 );
2660+ RB_GC_GUARD (source );
2661+ return result ;
26582662}
26592663
26602664/*
@@ -2732,7 +2736,9 @@ io_buffer_set_string(int argc, VALUE *argv, VALUE self)
27322736 const void * source_base = RSTRING_PTR (string );
27332737 size_t source_size = RSTRING_LEN (string );
27342738
2735- return io_buffer_copy_from (buffer , source_base , source_size , argc - 1 , argv + 1 );
2739+ VALUE result = io_buffer_copy_from (buffer , source_base , source_size , argc - 1 , argv + 1 );
2740+ RB_GC_GUARD (string );
2741+ return result ;
27362742}
27372743
27382744void
0 commit comments