@@ -375,6 +375,7 @@ static VALUE nogvl_use_result(void *ptr) {
375
375
static VALUE rb_mysql_client_async_result (VALUE self ) {
376
376
MYSQL_RES * result ;
377
377
VALUE resultObj ;
378
+ VALUE current , is_streaming ;
378
379
GET_CLIENT (self );
379
380
380
381
/* if we're not waiting on a result, do nothing */
@@ -388,7 +389,7 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
388
389
return rb_raise_mysql2_error (wrapper );
389
390
}
390
391
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 );
392
393
if (is_streaming == Qtrue ) {
393
394
result = (MYSQL_RES * )rb_thread_blocking_region (nogvl_use_result , wrapper , RUBY_UBF_IO , 0 );
394
395
} else {
@@ -404,7 +405,11 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
404
405
return Qnil ;
405
406
}
406
407
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
+
408
413
return resultObj ;
409
414
}
410
415
@@ -549,10 +554,13 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
549
554
REQUIRE_CONNECTED (wrapper );
550
555
args .mysql = wrapper -> client ;
551
556
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
+
554
562
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 );
556
564
557
565
if (rb_hash_aref (current , sym_async ) == Qtrue ) {
558
566
async = 1 ;
@@ -930,6 +938,7 @@ static VALUE rb_mysql_client_store_result(VALUE self)
930
938
{
931
939
MYSQL_RES * result ;
932
940
VALUE resultObj ;
941
+ VALUE current ;
933
942
GET_CLIENT (self );
934
943
935
944
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)
942
951
return Qnil ;
943
952
}
944
953
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 );
947
958
959
+ return resultObj ;
948
960
}
949
961
950
962
#ifdef HAVE_RUBY_ENCODING_H
0 commit comments