From: Scott MacVicar Date: Thu, 25 Jun 2009 00:07:20 +0000 (+0000) Subject: MFH Fix bug #48679 - Crash in SQLite with count on an unbuffered query set X-Git-Tag: php-5.2.11RC1~236 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bcf5793b56d9b9eaa991b5dafbc58196dc303cb1;p=php MFH Fix bug #48679 - Crash in SQLite with count on an unbuffered query set --- diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index 78b9857fc3..296b68437a 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -2481,6 +2481,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-- + +--FILE-- +getMessage()); +} +echo "Done\n"; +?> +--EXPECT-- +string(41) "Row count is not available for this query" +Done