summaryrefslogtreecommitdiff
path: root/ext/sqlite3
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-12-07 07:43:09 -0800
committerXinchen Hui <laruence@gmail.com>2015-12-07 07:43:09 -0800
commit250430acdc230ae9a894b8939653aad6fad537ce (patch)
tree82b7500e1ebdc93838d560d25f53d617d06a9967 /ext/sqlite3
parent6ac12f13379f3fc19f07abb9d1055274e5f98838 (diff)
downloadphp-git-250430acdc230ae9a894b8939653aad6fad537ce.tar.gz
Fixed Bug #71049 (SQLite3Stmt::execute() releases bound parameter instead of internal buffer)
Diffstat (limited to 'ext/sqlite3')
-rw-r--r--ext/sqlite3/sqlite3.c3
-rw-r--r--ext/sqlite3/tests/bug71049.phpt21
2 files changed, 22 insertions, 2 deletions
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 4e3cc28eda..755934376b 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -1536,8 +1536,7 @@ PHP_METHOD(sqlite3stmt, execute)
}
buffer = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0);
} else {
- convert_to_string(parameter);
- buffer = Z_STR_P(parameter);
+ buffer = zval_get_string(parameter);
}
if (buffer) {
diff --git a/ext/sqlite3/tests/bug71049.phpt b/ext/sqlite3/tests/bug71049.phpt
new file mode 100644
index 0000000000..5c2843f345
--- /dev/null
+++ b/ext/sqlite3/tests/bug71049.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Bug #71049 (SQLite3Stmt::execute() releases bound parameter instead of internal buffer)
+--SKIPIF--
+<?php
+if (!extension_loaded('sqlite3')) die('skip'); ?>
+--FILE--
+<?php
+
+require(__DIR__ . '/new_db.inc');
+
+$db->exec('CREATE TABLE test (age INTEGER, id STRING)');
+
+$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC");
+$foo = "alive" . chr(33);
+$stmt->bindParam(1, $foo, SQLITE3_BLOB);
+$results = $stmt->execute();
+var_dump($foo);
+$db->close();
+?>
+--EXPECT--
+string(6) "alive!"