prevent the GC from freeing a connection that hasn't been allocated yet

This commit is contained in:
Brian Lopez 2010-10-17 17:35:41 -07:00
parent 410e914411
commit 3c6959a8bb
1 changed files with 2 additions and 1 deletions

View File

@ -153,7 +153,7 @@ static VALUE allocate(VALUE klass) {
obj = Data_Make_Struct(klass, mysql_client_wrapper, rb_mysql_client_mark, rb_mysql_client_free, wrapper);
wrapper->encoding = Qnil;
wrapper->active = 0;
wrapper->closed = 0;
wrapper->closed = 1;
wrapper->client = (MYSQL*)malloc(sizeof(MYSQL));
return obj;
}
@ -517,6 +517,7 @@ static VALUE init_connection(VALUE self) {
return rb_raise_mysql2_error(wrapper->client);
}
wrapper->closed = 0;
return self;
}