From:             cataphract
Operating system: Windows 7 x64; Debian Lenny x64
PHP version:      trunk-SVN-2010-09-28 (SVN)
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:call_user_func_array still allows call-time pass-by-reference

Description:
------------
zend_call_function does not properly convert references into
non-references, hence allowing passing by reference arguments to functions
that expect values.



See also bug #43484.



This is harder to do with internal function because there's currently a
variable separation for those. However, it's still not impossible, because
if I'm not mistaken there are ways to make the engine give you a variable
with is_ref = 1, refcount  <= 1.



I propose making the behavior for internal functions consistent with that
of user functions by separating the variable all time if it's a reference
and the parameter is to be sent by value; for cases where is_ref = 1,
refcount <= 1, the reference flag should be cleared.

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

$a = 1;

function test($a) {

$a++;

}



test($a);

echo $a;



call_user_func_array('test', array(&$a));

echo $a;

Expected result:
----------------
11

Actual result:
--------------
12

-- 
Edit bug report at http://bugs.php.net/bug.php?id=52940&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52940&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52940&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52940&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52940&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52940&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52940&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52940&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52940&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52940&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52940&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52940&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52940&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52940&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52940&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52940&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52940&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52940&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52940&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52940&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52940&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52940&r=mysqlcfg

Reply via email to