Ruby opaque pointer handling regression fix
This bug was introduced in swig-3.0.8 in #146252 adding shared_ptr support. An ObjectPreviouslyDeleted error was incorrectly thrown when the pointer was used as a parameter after being set to zero via a call to 'DATA_PTR(self) = 0'. It isn't clear to me which approach is better in this corner case, so I've gone for backwards compatibility and restored the old behaviour. Closes #602
This commit is contained in:
parent
dc1fad3f9b
commit
763827c2e1
5 changed files with 131 additions and 5 deletions
|
|
@ -305,6 +305,14 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
|
|||
|
||||
/* Do type-checking if type info was provided */
|
||||
if (ty) {
|
||||
if (ty->clientdata) {
|
||||
if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) {
|
||||
if (vptr == 0) {
|
||||
/* The object has already been deleted */
|
||||
return SWIG_ObjectPreviouslyDeletedError;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((c = SWIG_MangleStr(obj)) == NULL) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
|
@ -312,10 +320,6 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
|
|||
if (!tc) {
|
||||
return SWIG_ERROR;
|
||||
} else {
|
||||
if (vptr == 0) {
|
||||
/* The object has already been deleted */
|
||||
return SWIG_ObjectPreviouslyDeletedError;
|
||||
}
|
||||
if (ptr) {
|
||||
if (tc->type == ty) {
|
||||
*ptr = vptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue