Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj.

Closes #935
This commit is contained in:
William S Fulton 2017-04-20 18:51:45 +01:00
commit b4377488f7
2 changed files with 8 additions and 4 deletions

View file

@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 3.0.13 (in progress)
============================
2017-04-20: wsfulton
[Ruby] #586, #935 Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj.
2017-04-20: tamuratak
[Ruby] #930, #937 - Fix containers of std::shared_ptr.
Upcasting, const types (eg vector<shared_ptr<const T>>) and NULL/nullptr support added.

View file

@ -171,10 +171,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
swig_class *sklass;
VALUE klass;
VALUE obj;
if (!ptr)
return Qnil;
assert(type);
if (type->clientdata) {
sklass = (swig_class *) type->clientdata;
@ -182,7 +183,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
track = sklass->trackObjects;
if (track) {
obj = SWIG_RubyInstanceFor(ptr);
/* Check the object's type and make sure it has the correct type.
It might not in cases where methods do things like
downcast methods. */
@ -214,7 +215,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
obj = Data_Wrap_Struct(klass, 0, 0, ptr);
}
rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
return obj;
}