diff --git a/include/nbind/BindClass.h b/include/nbind/BindClass.h index 8c8bd81..705adb7 100644 --- a/include/nbind/BindClass.h +++ b/include/nbind/BindClass.h @@ -237,8 +237,14 @@ BindClassBase &BindWrapper :: getBindClass() { template void BindWrapper :: testInstance(v8::Local arg) { + BindClassBase &bindClass = getBindClass(); + + if(bindClass.superTemplate.IsEmpty()) { + throw(std::runtime_error("Unbound type")); + } + if( - !Nan::New(getBindClass().superTemplate)->HasInstance(arg) || + !Nan::New(bindClass.superTemplate)->HasInstance(arg) || arg->InternalFieldCount() != 1 ) { throw(std::runtime_error("Type mismatch")); diff --git a/include/nbind/v8/ValueObj.h b/include/nbind/v8/ValueObj.h index 8b84b16..eccf8da 100644 --- a/include/nbind/v8/ValueObj.h +++ b/include/nbind/v8/ValueObj.h @@ -49,7 +49,14 @@ static inline WireType makeExternal(TypeFlags flags, TargetType *ptr, ArgType && #endif // DUPLICATE_POINTERS unsigned int constructorNum = BindClass::getInstance().wrapperConstructorNum; - v8::Local constructor = Overloader::getDef(constructorNum).constructorJS->GetFunction(); + Nan::Callback *constructorJS = Overloader::getDef(constructorNum).constructorJS; + + if(constructorJS == nullptr) { + Nan::ThrowError("Unbound type"); + return(Nan::Undefined()); + } + + v8::Local constructor = constructorJS->GetFunction(); // TODO: first argument should be a unique marker of some kind.