Bug #61088 [PATCH]: Memory leak in readline_callback_handler_install

From: Date: Tue, 14 Feb 2012 18:14:43 +0000
Subject: Bug #61088 [PATCH]: Memory leak in readline_callback_handler_install
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-167513@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61088&edit=1 ID: 61088 Patch added by: nikic@php.net Reported by: nikic@php.net Summary: Memory leak in readline_callback_handler_install Status: Open Type: Bug Package: *General Issues PHP Version: Irrelevant Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2012-02-14 18:14:25] nikic@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

« previous php.bugs (#167513) next »