Skip to content

Commit 9e2df3b

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
2 parents eac277e + 01759c4 commit 9e2df3b

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

ext/mysqli/tests/bug72489.phpt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--TEST--
2+
Bug #72489 (PHP Crashes When Modifying Array Containing MySQLi Result Data)
3+
--SKIPIF--
4+
<?php
5+
require_once('skipif.inc');
6+
require_once('skipifconnectfailure.inc');
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require_once("connect.inc");
12+
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
13+
printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
14+
}
15+
16+
if (!$link->query("DROP TABLE IF EXISTS bug72489")) {
17+
printf("[002] [%d] %s\n", $link->errno, $link->error);
18+
}
19+
20+
if (!$link->query("CREATE TABLE bug72489 (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, code VARCHAR(30) NOT NULL)")) {
21+
printf("[003] [%d] %s\n", $link->errno, $link->error);
22+
}
23+
24+
$seedSQL = "INSERT INTO bug72489 (`code`) VALUES ('code1'), ('code2'), ('code3');";
25+
if (!$link->query($seedSQL)) {
26+
printf("[004] [%d] %s\n", $link->errno, $link->error);
27+
}
28+
29+
$subRow = array();
30+
31+
if (!$stmt = $link->prepare("SELECT id, code FROM bug72489")) {
32+
printf("[005] [%d] %s\n", $link->errno, $link->error);
33+
}
34+
35+
$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY);
36+
if (!$stmt->bind_result($subRow['id'], $subRow['code']) || !$stmt->execute()) {
37+
printf("[006] [%d] %s\n", $link->errno, $link->error);
38+
}
39+
40+
while ($stmt->fetch()) {
41+
$testArray = array('id' => 1);
42+
$subRow['code'] = $testArray;
43+
}
44+
45+
echo "Finished 1\n";
46+
47+
$newArray = array();
48+
49+
echo "Finished 2\n";
50+
51+
?>
52+
--CLEAN--
53+
<?php
54+
require_once("connect.inc");
55+
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
56+
printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
57+
58+
if (!mysqli_query($link, "DROP TABLE IF EXISTS bug72489"))
59+
printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
60+
61+
mysqli_close($link);
62+
?>
63+
--EXPECTF--
64+
Finished 1
65+
Finished 2

0 commit comments

Comments
 (0)