#24519 [Opn->Fbk]: aggregate() doesn't increment methods' refcount
| From: | sniper@php.net | Date: | Mon, 07 Jul 2003 10:58:21 +0000 |
| Subject: | #24519 [Opn->Fbk]: aggregate() doesn't increment methods' refcount | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-43355@lists.php.net to get a copy of this message | ||
ID: 24519
Updated by: sniper@php.net
Reported By: d dot stogov at turck dot spb dot ru
-Status: Open
+Status: Feedback
Bug Type: Class/Object related
Operating System: Linux
PHP Version: 4.3.2
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2003-07-07 02:41:35] d dot stogov at turck dot spb dot ru
Description:
------------
Function aggregate() doesn't increment refcount fielld for aggregeted
methods. The result is rundom crash in destroy_op_array().
The patch over PHP 4.3.2 that solves this problem follows:
*** \php-4.3.2.orig\ext\standard\aggregation.c Mon Jul 07 07:38:02
2003
--- \php-4.3.2\ext\standard\aggregation.c Mon Jul 07 07:37:04 2003
*************** static void aggregate_methods(zend_class
*** 134,140 ****
*/
if (zend_hash_add(&ce->function_table, func_name,
func_name_len,
(void*)function, sizeof(zend_function), NULL) ==
SUCCESS) {
!
add_next_index_stringl(aggr_methods, func_name,
func_name_len-1, 1);
}
--- 134,140 ----
*/
if (zend_hash_add(&ce->function_table, func_name,
func_name_len,
(void*)function, sizeof(zend_function), NULL) ==
SUCCESS) {
! function_add_ref(function);
add_next_index_stringl(aggr_methods, func_name,
func_name_len-1, 1);
}
*************** static void aggregate_methods(zend_class
*** 155,160 ****
--- 155,161 ----
if (zend_hash_add(&ce->function_table, func_name,
func_name_len,
(void*)function, sizeof(zend_function), NULL) ==
SUCCESS) {
+ function_add_ref(function);
add_next_index_stringl(aggr_methods, func_name,
func_name_len-1, 1);
}
Reproduce code:
---------------
<?
class bar
{
function bar()
{
print "::bar";
}
function myMethod()
{
}
}
class foo
{
function foo()
{
print "::foo ";
aggregate($this, "bar");
bar::bar();
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24519&edit=1