summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2004-01-14 21:17:09 +0000
committerIlia Alshanetsky <iliaa@php.net>2004-01-14 21:17:09 +0000
commitb3853af0b7509d135b84e22e8caa3141ba5d9422 (patch)
treeba589f4019a0c61498d3869e6e95dca21713f1f8
parent8a40a946dead2672a3a5593183ca7d1a7736297e (diff)
downloadphp-git-b3853af0b7509d135b84e22e8caa3141ba5d9422.tar.gz
MFH: Fixed bug #26911 (crash in sqlite extension when fetching data from
empty queries).
-rw-r--r--NEWS2
-rw-r--r--ext/sqlite/sqlite.c3
-rw-r--r--ext/sqlite/tests/bug26911.phpt10
3 files changed, 15 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 7913a4b64e..ed8c930177 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ PHP NEWS
(Derick)
- Fixed problems with longlong values in mysqli. (Georg)
- Fixed class name case preserving of user defined classes. (Marcus)
+- Fixed bug #26911 (crash in sqlite extension when fetching data from empty
+ queries). (Ilia)
- Fixed bug #26819 (http_build_query() crashes on NULL output). (Ilia)
- Fixed bug #26817 (http_build_query() does not handle private & protected
object properties correctly). (Ilia)
diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c
index ba9c2b4296..74ed212f8c 100644
--- a/ext/sqlite/sqlite.c
+++ b/ext/sqlite/sqlite.c
@@ -1455,6 +1455,9 @@ void sqlite_query(zval *object, struct php_sqlite_db *db, char *sql, long sql_le
if (ret != SQLITE_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
sqlite_freemem(errtext);
+ goto terminate;
+ } else if (!res.vm) { /* empty query */
+terminate:
if (return_value) {
RETURN_FALSE;
} else {
diff --git a/ext/sqlite/tests/bug26911.phpt b/ext/sqlite/tests/bug26911.phpt
new file mode 100644
index 0000000000..e81aeae763
--- /dev/null
+++ b/ext/sqlite/tests/bug26911.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #26911 (crash when fetching data from empty queries)
+--FILE--
+<?php
+ $db = sqlite_open(":memory:");
+ $a = sqlite_query($db, " ");
+ echo "I am ok\n";
+?>
+--EXPECT--
+I am ok