php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62202 ReflectionParameter::getDefaultValue() memory leaks with constant
Submitted: 2012-06-01 06:13 UTC Modified: 2012-06-01 07:18 UTC
From: reeze dot xia at gmail dot com Assigned: laruence
Status: Closed Package: Reflection related
PHP Version: Irrelevant OS:
Private report: No CVE-ID:
 [2012-06-01 06:13 UTC] reeze dot xia at gmail dot com
Description:
------------
ReflectionParameter::getDefaultValue() memory leaks with constant.

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

define('TEST_CONST', '10');

class Foo {
    public function bar($param = TEST_CONST) {
        return $param;
    }
}

$refl_method = new ReflectionMethod('Foo::bar');

foreach ($refl_method->getParameters() as $param) {
    if ($param->isDefaultValueAvailable()) {
        var_dump($param->getDefaultValue());
    }
}
?>

Expected result:
----------------
string(2) "10"

Actual result:
--------------
string(2) "10"
[Fri Jun  1 14:09:29 2012]  Script:  '/Users/reeze/Opensource/php-src-
5.3/leak.php'
/Users/reeze/Opensource/php-src-5.3/ext/reflection/php_reflection.c(2424) :  
Freeing 0x10C8A69E8 (11 bytes), script=/Users/reeze/Opensource/php-src-
5.3/leak.php
/Users/reeze/Opensource/php-src-5.3/Zend/zend_variables.c(120) : Actual location 
(location was relayed)
=== Total 1 memory leaks detected ===

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-01 06:21 UTC] reeze dot xia at gmail dot com
Hi,
   I sent a PR here https://github.com/php/php-src/pull/97

Thanks:)
 [2012-06-01 06:57 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1f5327a6022fedc1985d2daa6d189313d808b08b
Log: Fixed Bug #62202 (ReflectionParameter::getDefaultValue() memory leaks with constant)
 [2012-06-01 07:00 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1f5327a6022fedc1985d2daa6d189313d808b08b
Log: Fixed Bug #62202 (ReflectionParameter::getDefaultValue() memory leaks with constant)
 [2012-06-01 07:01 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1f5327a6022fedc1985d2daa6d189313d808b08b
Log: Fixed Bug #62202 (ReflectionParameter::getDefaultValue() memory leaks with constant)
 [2012-06-01 07:18 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2012-06-01 07:18 UTC] laruence@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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 19:01:51 2014 UTC