com php-src: Add test for bug #72489: NEWS ext/mysqli/tests/bug72489.phpt

From: Date: Sat, 17 Sep 2016 20:54:25 +0000
Subject: com php-src: Add test for bug #72489: NEWS ext/mysqli/tests/bug72489.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-94579@lists.php.net to get a copy of this message
Commit: 01759c43463c30b57c15e32c5f4b454fba81f039 Author: Nikita Popov <nikic@php.net> Sat, 17 Sep 2016 22:54:25 +0200 Parents: 896814e139d8dead8193f0e44cdc4ba3d8a002c7 Branches: PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=01759c43463c30b57c15e32c5f4b454fba81f039 Log: Add test for bug #72489 Bugs: https://bugs.php.net/72489 Changed paths: M NEWS A ext/mysqli/tests/bug72489.phpt Diff: diff --git a/NEWS b/NEWS index a60224c..fe06a5c 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,10 @@ PHP NEWS . Fixed bug #72992 (mbstring.internal_encoding doesn't inherit default_charset). (Yasuo) +- Mysqlnd: + . Fixed bug #72489 (PHP Crashes When Modifying Array Containing MySQLi Result + Data).. (Nikita) + - Opcache: . Fixed bug #72982 (Memory leak in zend_accel_blacklist_update_regexp() function). (Laruence) diff --git a/ext/mysqli/tests/bug72489.phpt b/ext/mysqli/tests/bug72489.phpt new file mode 100644 index 0000000..4e8fb3f --- /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

« previous php.cvs (#94579) next »