зеркало из https://github.com/github/ruby.git
Multiple call of the initialize.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
45a08a4296
Коммит
9dab5bc3b0
|
@ -75,6 +75,9 @@ rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
Data_Get_Struct(self, struct dl_handle, dlhandle);
|
Data_Get_Struct(self, struct dl_handle, dlhandle);
|
||||||
|
if( dlhandle->ptr && dlhandle->open && dlhandle->enable_close ){
|
||||||
|
dlclose(dlhandle->ptr);
|
||||||
|
}
|
||||||
dlhandle->ptr = ptr;
|
dlhandle->ptr = ptr;
|
||||||
dlhandle->open = 1;
|
dlhandle->open = 1;
|
||||||
dlhandle->enable_close = 0;
|
dlhandle->enable_close = 0;
|
||||||
|
|
|
@ -202,6 +202,10 @@ rb_dlptr_initialize(int argc, VALUE argv[], VALUE self)
|
||||||
|
|
||||||
if( p ){
|
if( p ){
|
||||||
Data_Get_Struct(self, struct ptr_data, data);
|
Data_Get_Struct(self, struct ptr_data, data);
|
||||||
|
if( data->ptr && data->free ){
|
||||||
|
/* Free previous memory. Use of inappropriate initialize may cause SEGV. */
|
||||||
|
(*(data->free))(data->ptr);
|
||||||
|
}
|
||||||
data->ptr = p;
|
data->ptr = p;
|
||||||
data->size = s;
|
data->size = s;
|
||||||
data->free = f;
|
data->free = f;
|
||||||
|
|
|
@ -158,6 +158,8 @@ rb_dlsym_initialize(int argc, VALUE argv[], VALUE self)
|
||||||
|
|
||||||
if( saddr ){
|
if( saddr ){
|
||||||
Data_Get_Struct(self, struct sym_data, data);
|
Data_Get_Struct(self, struct sym_data, data);
|
||||||
|
if( data->name ) free(data->name);
|
||||||
|
if( data->type ) free(data->type);
|
||||||
data->func = saddr;
|
data->func = saddr;
|
||||||
data->name = sname ? strdup(sname) : 0;
|
data->name = sname ? strdup(sname) : 0;
|
||||||
data->type = stype ? strdup(stype) : 0;
|
data->type = stype ? strdup(stype) : 0;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче