Memory leak with .=

php.internals

Timm Friebe

22 years ago
The following script: <?php class StringBuffer { public $buf= ''; public function append($string) { $this->buf.= ($string instanceof StringBuffer ? $string->buf : $string ); } } $s= new StringBuffer(); $s->append('Hello'); ?> causes: /usr/home/thekid/devel/php/php/Zend/zend_execute.c(4049) : Freeing 0x083B0310 (6 bytes), script=string.php /usr/home/thekid/devel/php/php/Zend/zend_variables.c(137) : Actual location (location was relayed) === Total 1 memory leaks detected === Changing the line $this->buf.= [...] to $this->buf= $this->buf. makes the leak disappear. - Timm

Andi Gutmans

22 years ago
Fixed. Thanks for the reproducing case. At 11:25 PM 2/27/2004 +0100, Timm Friebe wrote:

Timm Friebe

22 years ago
On Tue, 2004-03-02 at 11:13, Andi Gutmans wrote:
> Fixed.
Verified.
> Thanks for the reproducing case.
You're welcome:) - Timm