@@ -375,6 +375,7 @@ static VALUE nogvl_use_result(void *ptr) {
375375static VALUE rb_mysql_client_async_result (VALUE self ) {
376376 MYSQL_RES * result ;
377377 VALUE resultObj ;
378+ VALUE current , is_streaming ;
378379 GET_CLIENT (self );
379380
380381 /* if we're not waiting on a result, do nothing */
@@ -388,7 +389,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
388389 return rb_raise_mysql2_error (wrapper );
389390 }
390391
391- VALUE is_streaming = rb_hash_aref (rb_iv_get (self , "@current_query_options" ), sym_stream );
392+ is_streaming = rb_hash_aref (rb_iv_get (self , "@current_query_options" ), sym_stream );
392393 if (is_streaming == Qtrue ) {
393394 result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_use_result , wrapper , RUBY_UBF_IO , 0 );
394395 } else {
@@ -404,7 +405,11 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
404405 return Qnil ;
405406 }
406407
407- resultObj = rb_mysql_result_to_obj (self , wrapper -> encoding , rb_hash_dup (rb_iv_get (self , "@current_query_options" )), result );
408+ current = rb_hash_dup (rb_iv_get (self , "@current_query_options" ));
409+ RB_GC_GUARD (current );
410+ Check_Type (current , T_HASH );
411+ resultObj = rb_mysql_result_to_obj (self , wrapper -> encoding , current , result );
412+
408413 return resultObj ;
409414}
410415
@@ -549,10 +554,13 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
549554 REQUIRE_CONNECTED (wrapper );
550555 args .mysql = wrapper -> client ;
551556
552- rb_iv_set (self , "@current_query_options" , rb_hash_dup (rb_iv_get (self , "@query_options" )));
553- current = rb_iv_get (self , "@current_query_options" );
557+ current = rb_hash_dup (rb_iv_get (self , "@query_options" ));
558+ RB_GC_GUARD (current );
559+ Check_Type (current , T_HASH );
560+ rb_iv_set (self , "@current_query_options" , current );
561+
554562 if (rb_scan_args (argc , argv , "11" , & args .sql , & opts ) == 2 ) {
555- opts = rb_funcall (current , intern_merge_bang , 1 , opts );
563+ rb_funcall (current , intern_merge_bang , 1 , opts );
556564
557565 if (rb_hash_aref (current , sym_async ) == Qtrue ) {
558566 async = 1 ;
@@ -930,6 +938,7 @@ static VALUE rb_mysql_client_store_result(VALUE self)
930938{
931939 MYSQL_RES * result ;
932940 VALUE resultObj ;
941+ VALUE current ;
933942 GET_CLIENT (self );
934943
935944 result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_store_result , wrapper , RUBY_UBF_IO , 0 );
@@ -942,9 +951,12 @@ static VALUE rb_mysql_client_store_result(VALUE self)
942951 return Qnil ;
943952 }
944953
945- resultObj = rb_mysql_result_to_obj (self , wrapper -> encoding , rb_hash_dup (rb_iv_get (self , "@current_query_options" )), result );
946- return resultObj ;
954+ current = rb_hash_dup (rb_iv_get (self , "@current_query_options" ));
955+ RB_GC_GUARD (current );
956+ Check_Type (current , T_HASH );
957+ resultObj = rb_mysql_result_to_obj (self , wrapper -> encoding , current , result );
947958
959+ return resultObj ;
948960}
949961
950962#ifdef HAVE_RUBY_ENCODING_H
0 commit comments