php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72347 VERIFY_RETURN type casts visible in finally
Submitted: 2016-06-06 16:52 UTC Modified: 2016-06-06 21:57 UTC
From: nikic@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: master-Git-2016-06-06 (Git) OS:
Private report: No CVE-ID: None
 [2016-06-06 16:52 UTC] nikic@php.net
Description:
------------
If VERIFY_RETURN leads to a type-cast on a CV return, the finally block will see the cast value rather than the original value.

Test script:
---------------
<?php
function test() : int {
    $d = 1.5;
    try {
        return $d;
    } finally {
        var_dump($d);
    }
}
test();


Expected result:
----------------
float(1.5)

Actual result:
--------------
int(1)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-06 16:52 UTC] nikic@php.net
-Assigned To: +Assigned To: nikic
 [2016-06-06 21:57 UTC] nikic@php.net
-Status: Assigned +Status: Open -Assigned To: nikic +Assigned To:
 [2016-06-06 21:57 UTC] nikic@php.net
I'm leaving this alone for now, as the case of by-reference return is somewhat tricky -- I'm not even sure how it should behave. Piling this into the general category of "finally return value bugs" we have open.
 [2016-07-13 12:09 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3b8cb2119b33ed6b7701d78d32eed63593cf61ff
Log: Fixed bug #72347 (VERIFY_RETURN type casts visible in finally) Fixed bug #72216 (Return by reference with finally is not memory safe) Fixed bug #72215 (Wrong return value if var modified in finally)
 [2016-07-13 12:09 UTC] dmitry@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:29 UTC] davey@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3b8cb2119b33ed6b7701d78d32eed63593cf61ff
Log: Fixed bug #72347 (VERIFY_RETURN type casts visible in finally) Fixed bug #72216 (Return by reference with finally is not memory safe) Fixed bug #72215 (Wrong return value if var modified in finally)
 [2016-10-17 10:11 UTC] bwoebi@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3b8cb2119b33ed6b7701d78d32eed63593cf61ff
Log: Fixed bug #72347 (VERIFY_RETURN type casts visible in finally) Fixed bug #72216 (Return by reference with finally is not memory safe) Fixed bug #72215 (Wrong return value if var modified in finally)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC