php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70299 Memleak while assigning object offsetGet result
Submitted: 2015-08-19 02:51 UTC Modified: 2015-08-19 02:57 UTC
From: laruence@php.net Assigned: laruence (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0.0beta3 OS:
Private report: No CVE-ID: None
 [2015-08-19 02:51 UTC] laruence@php.net
Description:
------------
this bug is fixed already by me last night while try to to fix SEND_REF bug #70288

anyway, it's better to have a bug entry for the record 

Test script:
---------------
<?php
class MyTree implements ArrayAccess {
    public $children = array();

    public function offsetExists($offset) {
    }

    public function offsetUnset($offset) {
    }

    public function offsetSet($offset, $value) {
        $this->children[$offset] = $value;
    }

    public function offsetGet($offset) {
        return $this->children[$offset];
    }

}

$root = new MyTree();
$root[0] = new MyTree();
$a  = &$root[0];
$b  = &$root[0];
$c  = &$root[0];
$d  = &$root[0];
?>

Expected result:
----------------
non memory leak

Actual result:
--------------
[Wed Aug 19 10:43:57 2015]  Script:  '/tmp/1.php'
/home/huixinchen/opensource/github/php-src/Zend/zend_objects.c(161) :  Freeing 0x7F2E4145A4E0 (56 bytes), script=/tmp/1.php
[Wed Aug 19 10:43:57 2015]  Script:  '/tmp/1.php'
/home/huixinchen/opensource/github/php-src/Zend/zend_execute.c(543) :  Freeing 0x7F2E414730A8 (24 bytes), script=/tmp/1.php
Last leak repeated 3 times
=== Total 5 memory leaks detected ===

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-19 02:57 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2015-08-19 02:57 UTC] laruence@php.net
The fix for this bug has been committed.

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC