Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index e19f5861366bf3ec06e15b666e07f77740f990de..3fef9cdd80f4d6597d0a684f56a576f514ee70ae 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -5665,14 +5665,22 @@ template<typename T> |
template<typename S> |
void ReturnValue<T>::Set(const Persistent<S>& handle) { |
TYPE_CHECK(T, S); |
- *value_ = *reinterpret_cast<internal::Object**>(*handle); |
+ if (V8_UNLIKELY(handle.IsEmpty())) { |
+ SetUndefined(); |
+ } else { |
+ *value_ = *reinterpret_cast<internal::Object**>(*handle); |
+ } |
} |
template<typename T> |
template<typename S> |
void ReturnValue<T>::Set(const Handle<S> handle) { |
TYPE_CHECK(T, S); |
- *value_ = *reinterpret_cast<internal::Object**>(*handle); |
+ if (V8_UNLIKELY(handle.IsEmpty())) { |
+ SetUndefined(); |
+ } else { |
+ *value_ = *reinterpret_cast<internal::Object**>(*handle); |
+ } |
} |
template<typename T> |