diff options
author | Johannes Schlüter <johannes@php.net> | 2009-06-25 09:38:04 +0000 |
---|---|---|
committer | Johannes Schlüter <johannes@php.net> | 2009-06-25 09:38:04 +0000 |
commit | 84940122a9e7898c239e97af8db13912b8e5ae91 (patch) | |
tree | 61b735bdd21a54598c26bc143ca8cbe63058c417 /ext/sqlite | |
parent | e01ff47c4372c249b9f195d5eda09bd76542c4d9 (diff) | |
download | php-git-84940122a9e7898c239e97af8db13912b8e5ae91.tar.gz |
MFH Fix bug #48679 - Crash in SQLite with count on an unbuffered query set (Scott)
Diffstat (limited to 'ext/sqlite')
-rw-r--r-- | ext/sqlite/sqlite.c | 5 | ||||
-rw-r--r-- | ext/sqlite/tests/bug48679.phpt | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index f1f8f60a27..f9b47c9a74 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -2819,6 +2819,11 @@ static int sqlite_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */ { sqlite_object *obj = (sqlite_object*) zend_object_store_get_object(object TSRMLS_CC); + if (obj->u.res == NULL) { + zend_throw_exception(sqlite_ce_exception, "Row count is not available for this query", 0 TSRMLS_CC); + return FAILURE; + } + if (obj->u.res->buffered) { * count = obj->u.res->nrows; return SUCCESS; diff --git a/ext/sqlite/tests/bug48679.phpt b/ext/sqlite/tests/bug48679.phpt new file mode 100644 index 0000000000..4b0c3f45cf --- /dev/null +++ b/ext/sqlite/tests/bug48679.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #48679 (sqlite2 count on unbuffered query causes segfault) +--SKIPIF-- +<?php +if (!extension_loaded("sqlite")) print "skip"; +?> +--FILE-- +<?php + +try { + $x = new sqliteunbuffered; + count($x); +} catch (SQLiteException $e) { + var_dump($e->getMessage()); +} +echo "Done\n"; +?> +--EXPECT-- +string(41) "Row count is not available for this query" +Done |