Edit report at https://bugs.php.net/bug.php?id=61088&edit=1

 ID:                 61088
 Updated by:         larue...@php.net
 Reported by:        ni...@php.net
 Summary:            Memory leak in readline_callback_handler_install
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            *General Issues
 PHP Version:        Irrelevant
 Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

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.




Previous Comments:
------------------------------------------------------------------------
[2012-03-11 09:19:29] larue...@php.net

Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&revision=324104
Log: Fixed bug #61088 (Memory leak in readline_callback_handler_install).

------------------------------------------------------------------------
[2012-02-14 18:14:43] ni...@php.net

The following patch has been added/updated:

Patch Name: readline.patch
Revision:   1329243283
URL:        
https://bugs.php.net/patch-display.php?bug=61088&patch=readline.patch&revision=1329243283

------------------------------------------------------------------------
[2012-02-14 18:14:25] ni...@php.net

Description:
------------
$callback = function() {};
readline_callback_handler_install('***', $callback);

Leaks:

***[Tue Feb 14 19:01:11 2012]  Script:  'reproduceCode3_memoryLeak.php'
/home/nikic/dev/php-src/ext/readline/readline.c(579) :  Freeing 0xB78618F4 (20 
bytes), script=reproduceCode3_memoryLeak.php
=== Total 1 memory leaks detected ===

Reason is incorrect copying of a zval in 
http://lxr.php.net/opengrok/xref/PHP_TRUNK/ext/readline/readline.c#579.

I was able to fix it using this simple patch:


diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 22521e6..c9389fc 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -576,9 +576,8 @@ PHP_FUNCTION(readline_callback_handler_install)
                FREE_ZVAL(_prepped_callback);
        }
 
-       MAKE_STD_ZVAL(_prepped_callback);
-       *_prepped_callback = *callback;
-       zval_copy_ctor(_prepped_callback);
+       ALLOC_ZVAL(_prepped_callback);
+       MAKE_COPY_ZVAL(&callback, _prepped_callback);
 
        rl_callback_handler_install(prompt, php_rl_callback_handler);




------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=61088&edit=1

Reply via email to