diff options
-rw-r--r-- | ext/sqlite3/sqlite3.c | 17 | ||||
-rw-r--r-- | ext/sqlite3/tests/bug68760.phpt | 5 |
2 files changed, 13 insertions, 9 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 556f7861f6..93a865ebfc 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -860,18 +860,23 @@ static int php_sqlite3_callback_compare(void *coll, int a_len, const void *a, in collation->fci.fci.params = zargs; - if ((ret = zend_call_function(&collation->fci.fci, &collation->fci.fcc)) == FAILURE) { - php_error_docref(NULL, E_WARNING, "An error occurred while invoking the compare callback"); + if (!EG(exception)) { + //Exception occurred on previous callback. Don't attempt to call function + if ((ret = zend_call_function(&collation->fci.fci, &collation->fci.fcc)) == FAILURE) { + php_error_docref(NULL, E_WARNING, "An error occurred while invoking the compare callback"); + } } zval_ptr_dtor(&zargs[0]); zval_ptr_dtor(&zargs[1]); efree(zargs); - //retval ought to contain a ZVAL_LONG by now - // (the result of a comparison, i.e. most likely -1, 0, or 1) - //I suppose we could accept any scalar return type, though. - if (Z_TYPE(retval) != IS_LONG){ + if (EG(exception)) { + ret = 0; + } else if (Z_TYPE(retval) != IS_LONG){ + //retval ought to contain a ZVAL_LONG by now + // (the result of a comparison, i.e. most likely -1, 0, or 1) + //I suppose we could accept any scalar return type, though. php_error_docref(NULL, E_WARNING, "An error occurred while invoking the compare callback (invalid return type). Collation behaviour is undefined."); }else{ ret = Z_LVAL(retval); diff --git a/ext/sqlite3/tests/bug68760.phpt b/ext/sqlite3/tests/bug68760.phpt index 5eb7d848bd..562fa48c9c 100644 --- a/ext/sqlite3/tests/bug68760.phpt +++ b/ext/sqlite3/tests/bug68760.phpt @@ -1,9 +1,9 @@ --TEST-- -Bug #68760 (Callback throws exception behaviour. Segfault in 5.6) +Bug #68760 (Callback throws exception behaviour.) --FILE-- <?php function oopsFunction($a, $b) { - echo "callback"; + echo "callback".PHP_EOL; throw new \Exception("oops"); } @@ -27,6 +27,5 @@ catch(\Exception $e) { ?> --EXPECTF-- callback -Warning: SQLite3::query(): An error occurred while invoking the compare callback in %a/bug68760.php on line %i Exception: oops |