summaryrefslogtreecommitdiff
path: root/ext/sqlite
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-06-30 19:11:48 +0200
committerSean Finney <seanius@debian.org>2009-06-30 19:11:48 +0200
commitd3a8757891280dc6650ca7eead67830c794b0e7b (patch)
treefd17e4142019fe7af4eeb7a5c9e0bdade5388418 /ext/sqlite
parent84f4ca9b07fe5b73d840258f4aa7c1eb534c4253 (diff)
downloadphp-d3a8757891280dc6650ca7eead67830c794b0e7b.tar.gz
Imported Upstream version 5.3.0upstream/5.3.0
Diffstat (limited to 'ext/sqlite')
-rw-r--r--ext/sqlite/sqlite.c9
-rw-r--r--ext/sqlite/tests/bug48679.phpt20
2 files changed, 27 insertions, 2 deletions
diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c
index 6e8aad13e..7f483659e 100644
--- a/ext/sqlite/sqlite.c
+++ b/ext/sqlite/sqlite.c
@@ -17,7 +17,7 @@
| Marcus Boerger <helly@php.net> |
+----------------------------------------------------------------------+
- $Id: sqlite.c,v 1.166.2.13.2.9.2.21 2009/03/22 15:05:20 iliaa Exp $
+ $Id: sqlite.c,v 1.166.2.13.2.9.2.22 2009/06/25 09:38:04 johannes Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -1458,7 +1458,7 @@ PHP_MINFO_FUNCTION(sqlite)
{
php_info_print_table_start();
php_info_print_table_header(2, "SQLite support", "enabled");
- php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.166.2.13.2.9.2.21 2009/03/22 15:05:20 iliaa Exp $");
+ php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.166.2.13.2.9.2.22 2009/06/25 09:38:04 johannes Exp $");
php_info_print_table_row(2, "SQLite Library", sqlite_libversion());
php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding());
php_info_print_table_end();
@@ -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 000000000..4b0c3f45c
--- /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