From d8f5f4de1db3c54bcb17d9371d740313789817c8 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Sat, 10 Jul 2010 10:32:46 -0700 Subject: [PATCH] on second thought, we should make sure we were given a string earlier on --- ext/mysql2/mysql2_ext.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/mysql2/mysql2_ext.c b/ext/mysql2/mysql2_ext.c index 7dbcd76..f252d9b 100644 --- a/ext/mysql2/mysql2_ext.c +++ b/ext/mysql2/mysql2_ext.c @@ -221,10 +221,11 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) { } } + Check_Type(args.sql, T_STRING); #ifdef HAVE_RUBY_ENCODING_H - rb_encoding *conn_enc = rb_to_encoding(rb_iv_get(self, "@encoding")); - // ensure the string is in the encoding the connection is expecting - args.sql = rb_str_export_to_enc(args.sql, conn_enc); + rb_encoding *conn_enc = rb_to_encoding(rb_iv_get(self, "@encoding")); + // ensure the string is in the encoding the connection is expecting + args.sql = rb_str_export_to_enc(args.sql, conn_enc); #endif Data_Get_Struct(self, MYSQL, client); @@ -265,6 +266,8 @@ static VALUE rb_mysql_client_escape(VALUE self, VALUE str) { MYSQL * client; VALUE newStr; unsigned long newLen, oldLen; + + Check_Type(str, T_STRING); #ifdef HAVE_RUBY_ENCODING_H rb_encoding *default_internal_enc = rb_default_internal_encoding(); rb_encoding *conn_enc = rb_to_encoding(rb_iv_get(self, "@encoding"));