Index: src/api.h |
diff --git a/src/api.h b/src/api.h |
index 6d7aaeab4adec09d6404310a530c842be86c82fe..b20ef5cf66f3cb401875ea40c1a3fca8b3e8045e 100644 |
--- a/src/api.h |
+++ b/src/api.h |
@@ -95,6 +95,7 @@ void NeanderObject::set(int offset, v8::internal::Object* value) { |
template <typename T> inline T ToCData(v8::internal::Object* obj) { |
STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address)); |
+ if (obj == v8::internal::Smi::FromInt(0)) return nullptr; |
return reinterpret_cast<T>( |
reinterpret_cast<intptr_t>( |
v8::internal::Foreign::cast(obj)->foreign_address())); |
@@ -105,6 +106,7 @@ template <typename T> |
inline v8::internal::Handle<v8::internal::Object> FromCData( |
v8::internal::Isolate* isolate, T obj) { |
STATIC_ASSERT(sizeof(T) == sizeof(v8::internal::Address)); |
+ if (obj == nullptr) return handle(v8::internal::Smi::FromInt(0), isolate); |
return isolate->factory()->NewForeign( |
reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(obj))); |
} |