Skip to content

Commit 250430a

Browse files
committed
Fixed Bug #71049 (SQLite3Stmt::execute() releases bound parameter instead of internal buffer)
1 parent 6ac12f1 commit 250430a

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ PHP NEWS
6767
- SPL:
6868
. Fixed bug #71028 (Undefined index with ArrayIterator). (Laruence)
6969

70+
- SQLite3:
71+
. Fixed bug #71049 (SQLite3Stmt::execute() releases bound parameter instead
72+
of internal buffer). (Laruence)
73+
7074
- Standard:
7175
. Fixed bug #70999 (php_random_bytes: called object is not a function).
7276
(Scott)

ext/sqlite3/sqlite3.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,8 +1536,7 @@ PHP_METHOD(sqlite3stmt, execute)
15361536
}
15371537
buffer = php_stream_copy_to_mem(stream, PHP_STREAM_COPY_ALL, 0);
15381538
} else {
1539-
convert_to_string(parameter);
1540-
buffer = Z_STR_P(parameter);
1539+
buffer = zval_get_string(parameter);
15411540
}
15421541

15431542
if (buffer) {

ext/sqlite3/tests/bug71049.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #71049 (SQLite3Stmt::execute() releases bound parameter instead of internal buffer)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('sqlite3')) die('skip'); ?>
6+
--FILE--
7+
<?php
8+
9+
require(__DIR__ . '/new_db.inc');
10+
11+
$db->exec('CREATE TABLE test (age INTEGER, id STRING)');
12+
13+
$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC");
14+
$foo = "alive" . chr(33);
15+
$stmt->bindParam(1, $foo, SQLITE3_BLOB);
16+
$results = $stmt->execute();
17+
var_dump($foo);
18+
$db->close();
19+
?>
20+
--EXPECT--
21+
string(6) "alive!"

0 commit comments

Comments
 (0)