diff options
author | Nikita Popov <nikic@php.net> | 2016-09-17 22:56:02 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2016-09-17 22:56:36 +0200 |
commit | 9e2df3b6b2d1f1e03e9701c3ed7e5479d7bae6d7 (patch) | |
tree | 1ea5e348d0db343fd30cacf77caed9e43e5602b4 | |
parent | eac277ed830e47f54bafdcce9122efec6749a292 (diff) | |
parent | 01759c43463c30b57c15e32c5f4b454fba81f039 (diff) | |
download | php-git-9e2df3b6b2d1f1e03e9701c3ed7e5479d7bae6d7.tar.gz |
Merge branch 'PHP-7.0' into PHP-7.1
-rw-r--r-- | ext/mysqli/tests/bug72489.phpt | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ext/mysqli/tests/bug72489.phpt b/ext/mysqli/tests/bug72489.phpt new file mode 100644 index 0000000000..4e8fb3f4e5 --- /dev/null +++ b/ext/mysqli/tests/bug72489.phpt @@ -0,0 +1,65 @@ +--TEST-- +Bug #72489 (PHP Crashes When Modifying Array Containing MySQLi Result Data) +--SKIPIF-- +<?php +require_once('skipif.inc'); +require_once('skipifconnectfailure.inc'); +?> +--FILE-- +<?php + +require_once("connect.inc"); +if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { + printf("[001] Connect failed, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); +} + +if (!$link->query("DROP TABLE IF EXISTS bug72489")) { + printf("[002] [%d] %s\n", $link->errno, $link->error); +} + +if (!$link->query("CREATE TABLE bug72489 (id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, code VARCHAR(30) NOT NULL)")) { + printf("[003] [%d] %s\n", $link->errno, $link->error); +} + +$seedSQL = "INSERT INTO bug72489 (`code`) VALUES ('code1'), ('code2'), ('code3');"; +if (!$link->query($seedSQL)) { + printf("[004] [%d] %s\n", $link->errno, $link->error); +} + +$subRow = array(); + +if (!$stmt = $link->prepare("SELECT id, code FROM bug72489")) { + printf("[005] [%d] %s\n", $link->errno, $link->error); +} + +$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY); +if (!$stmt->bind_result($subRow['id'], $subRow['code']) || !$stmt->execute()) { + printf("[006] [%d] %s\n", $link->errno, $link->error); +} + +while ($stmt->fetch()) { + $testArray = array('id' => 1); + $subRow['code'] = $testArray; +} + +echo "Finished 1\n"; + +$newArray = array(); + +echo "Finished 2\n"; + +?> +--CLEAN-- +<?php +require_once("connect.inc"); +if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) + printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); + +if (!mysqli_query($link, "DROP TABLE IF EXISTS bug72489")) + printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + +mysqli_close($link); +?> +--EXPECTF-- +Finished 1 +Finished 2 |