diff --git a/tests/php_exceptions_005.phpt b/tests/php_exceptions_005.phpt index 296cb45..aa559d5 100644 --- a/tests/php_exceptions_005.phpt +++ b/tests/php_exceptions_005.phpt @@ -34,7 +34,7 @@ catch(V8JsScriptException $e) { --EXPECTF-- after getException Got V8JsScriptException -string(%d) "php_exceptions_005:3: exception 'Exception' with message 'Test-Exception' in %s +string(%d) "php_exceptions_005:3: Exception: Test-Exception in %s Stack trace: #0 [internal function]: Foo->getException() #1 %s: V8Js->executeString('var ex = PHP.fo...', 'php_exceptions_...') diff --git a/v8js_exceptions.cc b/v8js_exceptions.cc index f0a6dec..7e5c89c 100644 --- a/v8js_exceptions.cc +++ b/v8js_exceptions.cc @@ -88,12 +88,12 @@ void v8js_create_script_exception(zval *return_value, v8::Isolate *isolate, v8:: if(!php_ref.IsEmpty()) { assert(php_ref->IsExternal()); - zval *php_exception = reinterpret_cast(v8::External::Cast(*php_ref)->Value()); + zend_object *php_exception = reinterpret_cast(v8::External::Cast(*php_ref)->Value()); zend_class_entry *exception_ce = zend_exception_get_default(TSRMLS_C); - if (Z_TYPE_P(php_exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(php_exception), exception_ce TSRMLS_CC)) { - Z_ADDREF_P(php_exception); - zend_exception_set_previous(Z_OBJ_P(return_value), Z_OBJ_P(php_exception)); + if (instanceof_function(php_exception->ce, exception_ce TSRMLS_CC)) { + ++GC_REFCOUNT(php_exception); + zend_exception_set_previous(Z_OBJ_P(return_value), php_exception); } } }