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) 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 2017-04-20: tamuratak
[Ruby] #930, #937 - Fix containers of std::shared_ptr. [Ruby] #930, #937 - Fix containers of std::shared_ptr.
Upcasting, const types (eg vector<shared_ptr<const T>>) and NULL/nullptr support added. 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; swig_class *sklass;
VALUE klass; VALUE klass;
VALUE obj; VALUE obj;
if (!ptr) if (!ptr)
return Qnil; return Qnil;
assert(type);
if (type->clientdata) { if (type->clientdata) {
sklass = (swig_class *) 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; track = sklass->trackObjects;
if (track) { if (track) {
obj = SWIG_RubyInstanceFor(ptr); obj = SWIG_RubyInstanceFor(ptr);
/* Check the object's type and make sure it has the correct type. /* Check the object's type and make sure it has the correct type.
It might not in cases where methods do things like It might not in cases where methods do things like
downcast methods. */ 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); obj = Data_Wrap_Struct(klass, 0, 0, ptr);
} }
rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
return obj; return obj;
} }