on second thought, we should make sure we were given a string earlier on

This commit is contained in:
Brian Lopez 2010-07-10 10:32:46 -07:00
parent 645b9a1bef
commit d8f5f4de1d

View File

@ -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 #ifdef HAVE_RUBY_ENCODING_H
rb_encoding *conn_enc = rb_to_encoding(rb_iv_get(self, "@encoding")); rb_encoding *conn_enc = rb_to_encoding(rb_iv_get(self, "@encoding"));
// ensure the string is in the encoding the connection is expecting // ensure the string is in the encoding the connection is expecting
args.sql = rb_str_export_to_enc(args.sql, conn_enc); args.sql = rb_str_export_to_enc(args.sql, conn_enc);
#endif #endif
Data_Get_Struct(self, MYSQL, client); Data_Get_Struct(self, MYSQL, client);
@ -265,6 +266,8 @@ static VALUE rb_mysql_client_escape(VALUE self, VALUE str) {
MYSQL * client; MYSQL * client;
VALUE newStr; VALUE newStr;
unsigned long newLen, oldLen; unsigned long newLen, oldLen;
Check_Type(str, T_STRING);
#ifdef HAVE_RUBY_ENCODING_H #ifdef HAVE_RUBY_ENCODING_H
rb_encoding *default_internal_enc = rb_default_internal_encoding(); rb_encoding *default_internal_enc = rb_default_internal_encoding();
rb_encoding *conn_enc = rb_to_encoding(rb_iv_get(self, "@encoding")); rb_encoding *conn_enc = rb_to_encoding(rb_iv_get(self, "@encoding"));