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

@ -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;
}