cellog Sat Jun 13 17:30:50 2009 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/spl/tests spl_autoload_bug48541.phpt
Modified files:
/php-src NEWS
/php-src/ext/spl php_spl.c
Log:
fix Bug #48541: spl_autoload_register only registers first closure, then
leaks the others. Fix missing erealloc in fix for bug #40091 (PHP_5_3 only)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.625&r2=1.2027.2.547.2.965.2.626&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.625
php-src/NEWS:1.2027.2.547.2.965.2.626
--- php-src/NEWS:1.2027.2.547.2.965.2.625 Sat Jun 13 16:43:04 2009
+++ php-src/NEWS Sat Jun 13 17:30:49 2009
@@ -3,8 +3,12 @@
?? ??? 2009, PHP 5.3.0 RC 4
- Added phar.phar generation for Windows. (Greg)
+- Fixed bug #48541 (spl_autoload_register only registers first closure, then
+ leaks the others). (Greg)
- Fixed bug #48533 (__callStatic is not invoked for private/protected methods).
(Felipe)
+- Fixed missing erealloc() in fix for Bug #40091 in spl_autoload_register.
+ (Greg)
11 Jun 2009, PHP 5.3.0 RC 3
- Upgraded bundled sqlite to version 3.6.14.2. (Scott, Ilia)
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.17.2.37&r2=1.52.2.28.2.17.2.38&diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.37
php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.38
--- php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.37 Tue Jun 9 01:58:07 2009
+++ php-src/ext/spl/php_spl.c Sat Jun 13 17:30:50 2009
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_spl.c,v 1.52.2.28.2.17.2.37 2009/06/09 01:58:07 scottmac Exp $ */
+/* $Id: php_spl.c,v 1.52.2.28.2.17.2.38 2009/06/13 17:30:50 cellog Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -497,10 +497,6 @@
alfi.ce = fcc.calling_scope;
alfi.func_ptr = fcc.function_handler;
obj_ptr = fcc.object_ptr;
- if (Z_TYPE_P(zcallable) == IS_OBJECT) {
- alfi.closure = zcallable;
- Z_ADDREF_P(zcallable);
- }
if (error) {
efree(error);
}
@@ -509,12 +505,27 @@
zend_str_tolower_copy(lc_name, func_name, func_name_len);
efree(func_name);
+ if (Z_TYPE_P(zcallable) == IS_OBJECT) {
+ alfi.closure = zcallable;
+ Z_ADDREF_P(zcallable);
+
+ lc_name = erealloc(lc_name, func_name_len + 2 +
sizeof(zcallable->value.obj.handle));
+ memcpy(lc_name + func_name_len,
&(zcallable->value.obj.handle),
+ sizeof(zcallable->value.obj.handle));
+ func_name_len += sizeof(zcallable->value.obj.handle);
+ lc_name[func_name_len] = '\0';
+ }
+
if (SPL_G(autoload_functions) &&
zend_hash_exists(SPL_G(autoload_functions), (char*)lc_name, func_name_len+1)) {
+ if (alfi.closure) {
+ Z_DELREF_P(zcallable);
+ }
goto skip;
}
if (obj_ptr && !(alfi.func_ptr->common.fn_flags &
ZEND_ACC_STATIC)) {
/* add object id to the hash to ensure uniqueness, for
more reference look at bug #40091 */
+ lc_name = erealloc(lc_name, func_name_len + 2 +
sizeof(zend_object_handle));
memcpy(lc_name + func_name_len,
&Z_OBJ_HANDLE_P(obj_ptr), sizeof(zend_object_handle));
func_name_len += sizeof(zend_object_handle);
lc_name[func_name_len] = '\0';
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/spl_autoload_bug48541.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/spl_autoload_bug48541.phpt
+++ php-src/ext/spl/tests/spl_autoload_bug48541.phpt
--TEST--
SPL: spl_autoload_register() Bug #48541: registering multiple closures fails
with memleaks
--FILE--
<?php
$a = function ($class) {
echo "a called\n";
};
$b = function ($class) {
eval('class ' . $class . '{function __construct(){echo "foo\n";}}');
echo "b called\n";
};
spl_autoload_register($a);
spl_autoload_register($b);
$c = $a;
spl_autoload_register($c);
$c = new foo;
?>
===DONE===
--EXPECT--
a called
b called
foo
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php