0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-09 15:18:41 +00:00

Don't restore original error handler when exiting inner frame, refs #94

This commit is contained in:
Stefan Siegl 2014-05-23 00:35:51 +02:00
parent 847ac7677c
commit 1fc79f8223
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,30 @@
--TEST--
Test V8::executeString() : Fatal Error handler not to uninstall on inner frames
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php
$js = new V8Js();
$js->bar = function() {
echo "nothing.\n";
};
$js->foo = function() {
global $js;
// call to JS context, this must not touch the error handling context
$js->executeString("PHP.bar();");
$bar = null;
$bar->foo();
};
$js->executeString("PHP.foo();");
?>
===EOF===
--EXPECTF--
nothing.
Fatal error: Call to a member function foo() on a non-object in %s/fatal_error_no_uninstall_inner_frame.php on line 15

View File

@ -167,11 +167,13 @@ static void php_v8js_call_php_func(zval *value, zend_class_entry *ce, zend_funct
jmp_buf env;
int val = 0;
bool installed_handler = false;
/* If this is the first level call from V8 back to PHP, install a
* handler for fatal errors; we must fall back through V8 to keep
* it from crashing. */
if (V8JSG(unwind_env) == NULL) {
installed_handler = true;
V8JSG(old_error_handler) = zend_error_cb;
zend_error_cb = php_v8js_error_handler;
@ -184,7 +186,7 @@ static void php_v8js_call_php_func(zval *value, zend_class_entry *ce, zend_funct
zend_call_function(&fci, &fcc TSRMLS_CC);
}
if (V8JSG(old_error_handler) != NULL) {
if (installed_handler) {
zend_error_cb = V8JSG(old_error_handler);
V8JSG(unwind_env) = NULL;
}