php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51911 ReflectionParameter::getDefaultValue() memory leaks with constant array
Submitted: 2010-05-26 00:41 UTC Modified: 2010-05-26 00:46 UTC
From: felipe@php.net Assigned: felipe
Status: Closed Package: Reflection related
PHP Version: Irrelevant OS: *
Private report: No CVE-ID:
 [2010-05-26 00:41 UTC] felipe@php.net
Description:
------------
See below.

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

class Foo {
   const X = 1;
   public function x($x = array(1)) {}
}

$clazz = new ReflectionClass('Foo');
$method = $clazz->getMethod('x');
foreach ($method->getParameters() as $param) {
    if ( $param->isDefaultValueAvailable())
        echo '$', $param->getName(), ' : ', var_export($param->getDefaultValue(), 1), "\n";
}

Expected result:
----------------
No memleak. :)

Actual result:
--------------
$ sapi/cli/php ../bug.php 
$x : array (
  0 => 1,
)
[Tue May 25 19:40:32 2010]  Script:  '../bug.php'
/home/felipe/dev/php5_2/Zend/zend_compile.c(3415) :  Freeing 0x08646078 (16 bytes), script=../bug.php
[Tue May 25 19:40:32 2010]  Script:  '../bug.php'
/home/felipe/dev/php5_2/ext/reflection/php_reflection.c(2174) :  Freeing 0x08648CA4 (44 bytes), script=../bug.php
/home/felipe/dev/php5_2/Zend/zend_variables.c(131) : Actual location (location was relayed)
[Tue May 25 19:40:32 2010]  Script:  '../bug.php'
/home/felipe/dev/php5_2/Zend/zend_variables.c(132) :  Freeing 0x08648D00 (32 bytes), script=../bug.php
/home/felipe/dev/php5_2/Zend/zend_alloc.c(2391) : Actual location (location was relayed)
[Tue May 25 19:40:32 2010]  Script:  '../bug.php'
/home/felipe/dev/php5_2/Zend/zend_hash.c(788) :  Freeing 0x08648D50 (35 bytes), script=../bug.php
/home/felipe/dev/php5_2/Zend/zend_hash.c(388) : Actual location (location was relayed)
=== Total 4 memory leaks detected ===


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-26 00:41 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: felipe
 [2010-05-26 00:46 UTC] felipe@php.net
-Status: Assigned +Status: Closed
 [2010-05-26 00:46 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-05-26 00:46 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=299763
Log: - Fixed bug #51911 (ReflectionParameter::getDefaultValue() memory leaks with constant array)
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 10:03:03 2014 UTC