php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80668 passed by reference upgraded from notice to error
Submitted: 2021-01-25 14:00 UTC Modified: 2021-01-25 14:37 UTC
From: b dot lau at tamrael dot de Assigned: cmb (profile)
Status: Duplicate Package: Reproducible crash
PHP Version: 7.4.14 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: b dot lau at tamrael dot de
New email:
PHP Version: OS:

 

 [2021-01-25 14:00 UTC] b dot lau at tamrael dot de
Description:
------------
Since php version 7.4.9 and later, passing any non-variable to a function that expects a reference results in an error.

From 7.1.0 to 7.4.8 the same would produce no warning, notice or anything and just work.
Before 7.1.0 this would issue a notice but still execute the code.
In 5.0.5 this would crash with an error.

Maybe this is missing documentation and not a bug but changing behavior like this inside a minor version shouldn't be intended.

See https://3v4l.org/iUp7Q

Test script:
---------------
<?php

function test(&$var)
{
    return $var;
}

echo test(strval('var'));

Expected result:
----------------
Output of "var" and a notice

Actual result:
--------------
fatal error

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-25 14:18 UTC] nikic@php.net
This only affects cases where the passed function is a VM primitive (here "strval" is a cast).
 [2021-01-25 14:24 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-01-25 14:24 UTC] cmb@php.net
This is a duplicate of bug #80486.  Note that we have not
documented this in any changelog, since that only worked
coincidentally.
 [2021-01-25 14:28 UTC] b dot lau at tamrael dot de
I'm so sorry.
I swear I used the search but the linked bug wasn't showing up for me.

Thank you for the fast reply.
 [2021-01-25 14:37 UTC] cmb@php.net
I tried the search as well, and also failed to find the ticket. :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC