diff options
| author | Stanislav Malyshev <stas@php.net> | 2015-03-22 16:48:54 -0700 |
|---|---|---|
| committer | Stanislav Malyshev <stas@php.net> | 2015-03-22 16:48:54 -0700 |
| commit | 5a5b63774b12e5f49c28c48fe7bec8293425b2ff (patch) | |
| tree | cad35910cf8416d2d8454406a85f1ee50f3943b4 /ext/sqlite3/sqlite3.c | |
| parent | 574b9a4e609d862bc5f384ffcbbc1bcbe95b936b (diff) | |
| parent | 44f15b068d40eb3750864af54126ef25b238e412 (diff) | |
| download | php-git-5a5b63774b12e5f49c28c48fe7bec8293425b2ff.tar.gz | |
Merge branch 'pull-request/1091'
* pull-request/1091:
Stop trying to call the callback after it has thrown an exception. Also, as an exception has been thrown, there is no need to have a separate error message.
Fix freeing null segfault. Added test for behaviour.
Conflicts:
ext/sqlite3/tests/bug68760.phpt
Diffstat (limited to 'ext/sqlite3/sqlite3.c')
| -rw-r--r-- | ext/sqlite3/sqlite3.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 044d4f3e69..f1e759229a 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); |
