summaryrefslogtreecommitdiff
path: root/Lib/ruby/rubyrun.swg
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/ruby/rubyrun.swg')
-rw-r--r--Lib/ruby/rubyrun.swg11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
index e4c23bde5..6cac4626a 100644
--- a/Lib/ruby/rubyrun.swg
+++ b/Lib/ruby/rubyrun.swg
@@ -281,6 +281,11 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
own->own = 0;
}
+ if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE)) {
+ if (!RDATA(obj)->dfree)
+ return SWIG_ERROR_RELEASE_NOT_OWNED;
+ }
+
/* Check to see if the input object is giving up ownership
of the underlying C struct or C++ object. If so then we
need to reset the destructor since the Ruby object no
@@ -292,7 +297,7 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
swig_class *sklass = (swig_class *) ty->clientdata;
track = sklass->trackObjects;
}
-
+
if (track) {
/* We are tracking objects for this class. Thus we change the destructor
* to SWIG_RubyRemoveTracking. This allows us to
@@ -306,6 +311,10 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
}
}
+ if (flags & SWIG_POINTER_CLEAR) {
+ DATA_PTR(obj) = 0;
+ }
+
/* Do type-checking if type info was provided */
if (ty) {
if (ty->clientdata) {