From: Scott MacVicar Date: Thu, 25 Jun 2009 00:04:07 +0000 (+0000) Subject: Fix bug #48679 - Crash in SQLite with count on an unbuffered query set X-Git-Tag: php-5.4.0alpha1~191^2~3243 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0dc0af527beec33a05571c4c1096dcb48ce7153a;p=php 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 91b37f5c28..01c52eda49 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -3021,6 +3021,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..1961179cce --- /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-- +unicode(41) "Row count is not available for this query" +Done