?? ??? 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)
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);
}
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';
--- /dev/null
+--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===
\ No newline at end of file