{
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;
--- /dev/null
+--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--
+unicode(41) "Row count is not available for this query"
+Done