php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41115 Memory leak when creating object from empty value
Submitted: 2007-04-17 12:08 UTC Modified: 2007-12-28 14:14 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: hannes dot magnusson at gmail dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2007-04-17 (CVS) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: hannes dot magnusson at gmail dot com
New email:
PHP Version: OS:

 

 [2007-04-17 12:08 UTC] hannes dot magnusson at gmail dot com
Description:
------------
Creating an object from an empty value on overloaded element leaks.

Reproduce code:
---------------
<?php
class foo implements ArrayAccess {
        private $array;
        public function offsetSet($key, $value) {
                $this->array[$key] = $value;
        }
        public function offsetGet($key) {
                return $this->array[$key];
        }
        public function offsetExists($key) {}
        public function offsetUnset($key) {}
}
$foo = new foo;

$foo["bar"] = array();
$foo["bar"][0]->std = "foo";



Actual result:
--------------
Notice: Indirect modification of overloaded element of foo has no effect in /usr/home/bjori/test/memleak.php on line 16

Strict Standards: Creating default object from empty value in /usr/home/bjori/test/memleak.php on line 16
[Tue Apr 17 14:02:54 2007]  Script:  'memleak.php'
/usr/src/php/5.2/Zend/zend_execute.c(441) :  Freeing 0x0850535C (16 bytes), script=memleak.php
=== Total 1 memory leaks detected ===


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-17 23:26 UTC] jani@php.net
Stas, you seem to have added the code where the leak emits from.. :)
 [2007-11-05 21:24 UTC] stas@php.net
Couldn't reproduce it in neither 5.2 nor 5.3 HEAD. Does it still happen for you? 
 [2007-11-05 21:42 UTC] hannes dot magnusson at gmail dot com
PHP Notice:  Indirect modification of overloaded element of foo has no effect in /home/bjori/php/- on line 16
[Mon Nov  5 22:37:52 2007]  Script:  '-'
/home/bjori/php/5.3/Zend/zend_execute.c(453) :  Freeing 0x086228D8 (16 bytes), script=-
=== Total 1 memory leaks detected ===
 [2007-12-28 14:14 UTC] dmitry@php.net
The bug seems to be fixed some time ago.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 07:01:32 2025 UTC