From 84940122a9e7898c239e97af8db13912b8e5ae91 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Schl=C3=BCter?= Date: Thu, 25 Jun 2009 09:38:04 +0000 Subject: [PATCH] MFH Fix bug #48679 - Crash in SQLite with count on an unbuffered query set (Scott) --- ext/sqlite/sqlite.c | 5 +++++ ext/sqlite/tests/bug48679.phpt | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 ext/sqlite/tests/bug48679.phpt 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-- + +--FILE-- +getMessage()); +} +echo "Done\n"; +?> +--EXPECT-- +string(41) "Row count is not available for this query" +Done -- 2.40.0