Skip to content

Commit 24b40bc

Browse files
committed
add test
1 parent 7c59735 commit 24b40bc

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
mysqli_execute_query() does not leak stmt->query on input_params validation errors with MYSQLI_REPORT_INDEX
3+
--EXTENSIONS--
4+
mysqli
5+
--SKIPIF--
6+
<?php
7+
require_once 'skipifconnectfailure.inc';
8+
?>
9+
--FILE--
10+
<?php
11+
12+
require 'table.inc';
13+
14+
mysqli_report(MYSQLI_REPORT_INDEX);
15+
16+
try {
17+
$link->execute_query('SELECT label, ? AS anon, ? AS num FROM test WHERE id=?', ['foo', 42]);
18+
} catch (ValueError $e) {
19+
echo '[001] '.$e->getMessage()."\n";
20+
}
21+
22+
try {
23+
$link->execute_query('SELECT label, ? AS anon, ? AS num FROM test WHERE id=?', ['foo' => 42]);
24+
} catch (ValueError $e) {
25+
echo '[002] '.$e->getMessage()."\n";
26+
}
27+
28+
print "done!";
29+
?>
30+
--CLEAN--
31+
<?php
32+
require_once 'clean_table.inc';
33+
?>
34+
--EXPECT--
35+
[001] mysqli::execute_query(): Argument #2 ($params) must consist of exactly 3 elements, 2 present
36+
[002] mysqli::execute_query(): Argument #2 ($params) must be a list array
37+
done!

0 commit comments

Comments
 (0)