Bug #81040 [NEW]: Native pass-by-ref in mysqli_stmt::bind_param leaks reference

From: Date: Thu, 13 May 2021 16:30:51 +0000
Subject: Bug #81040 [NEW]: Native pass-by-ref in mysqli_stmt::bind_param leaks reference
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233822@lists.php.net to get a copy of this message
From: dharman Operating system: Windows 10 PHP version: 8.0.6 Package: Unknown/Other Function Bug Type: Bug Bug description:Native pass-by-ref in mysqli_stmt::bind_param leaks reference Description: ------------ Native pass-by-reference makes elements of an array referenced. Tested with mysqli_stmt::bind_param. This results in inadvertent changes to follow up code, e.g. results from array_diff() I don't know if it's intended behaviour or if not then which component this is related to. Additionally, should the reference leak through array_diff()? Test online: https://phpize.online/?phpses=6fd2785a4408856aa1fc2aba245d05bc&sqlses=null&php_version=php8&sql_version=mysql57 Test script: --------------- <?php mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); $mysqli = new mysqli('localhost', 'user', 'password', 'test'); function a(&$a, &$b, &$c) { $a = 3; } $foo = [1, 2, 3]; $bar = [3, 4, 5]; $stmt = $mysqli->prepare("SELECT ?,?,?"); // What's the difference between this $stmt->bind_param('sss', $foo[0], $foo[1], $foo[2]); // and this a($foo[0], $foo[1], $foo[2]); $diff = array_diff($foo, $bar); $foo[1] = 'hi'; var_dump($diff); Expected result: ---------------- array(1) { [1] => int(2) } Actual result: -------------- array(1) { [1] => string(2) "hi" } -- Edit bug report at https://bugs.php.net/bug.php?id=81040&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81040&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81040&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81040&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81040&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81040&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81040&r=support Expected behavior: https://bugs.php.net/fix.php?id=81040&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81040&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81040&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81040&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81040&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81040&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81040&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81040&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81040&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81040&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81040&r=mysqlcfg

« previous php.bugs (#233822) next »