felipe          Thu Nov 20 22:23:53 2008 UTC

  Added files:                 
    /php-src/ext/readline/tests readline_completion_function_001.phpt 

  Modified files:              
    /php-src/ext/readline       readline.c 
  Log:
  - Fixed memory leaks in readline_completion_function()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/readline/readline.c?r1=1.57&r2=1.58&diff_format=u
Index: php-src/ext/readline/readline.c
diff -u php-src/ext/readline/readline.c:1.57 
php-src/ext/readline/readline.c:1.58
--- php-src/ext/readline/readline.c:1.57        Mon Nov 17 11:26:23 2008
+++ php-src/ext/readline/readline.c     Thu Nov 20 22:23:53 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: readline.c,v 1.57 2008/11/17 11:26:23 felipe Exp $ */
+/* $Id: readline.c,v 1.58 2008/11/20 22:23:53 felipe Exp $ */
 
 /* {{{ includes & prototypes */
 
@@ -169,8 +169,10 @@
 
 PHP_RSHUTDOWN_FUNCTION(readline)
 {
-       if (_readline_completion) 
+       if (_readline_completion) {
+               zval_dtor(_readline_completion);
                FREE_ZVAL(_readline_completion);
+       }
 #if HAVE_RL_CALLBACK_READ_CHAR
        if (_prepped_callback) {
                rl_callback_handler_remove();
@@ -494,6 +496,7 @@
        zval_dtor(&name);
 
        if (_readline_completion) {
+               zval_dtor(_readline_completion);
                FREE_ZVAL(_readline_completion);
        }
 

http://cvs.php.net/viewvc.cgi/php-src/ext/readline/tests/readline_completion_function_001.phpt?view=markup&rev=1.1
Index: php-src/ext/readline/tests/readline_completion_function_001.phpt
+++ php-src/ext/readline/tests/readline_completion_function_001.phpt
--TEST--
readline_completion_function(): Basic test
--SKIPIF--
<?php if (!extension_loaded("readline")) die("skip"); ?>
--FILE--
<?php

function foo() { }

$data = array(
        'foo',
        'strtolower',
        1,
        1.1231
);

foreach ($data as $callback) {
        readline_completion_function($callback);
}

?>
--EXPECTF--
Warning: readline_completion_function(): 1 is not callable in %s on line %d

Warning: readline_completion_function(): 1.1231 is not callable in %s on line %d



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to