|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2003-07-07 02:41 UTC] 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(); 
} 
} 
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 03:00:01 2025 UTC | 
--- aggregation.c.orig Tue Jul 08 05:25:12 2003 +++ aggregation.c Tue Jul 08 05:24:52 2003 @@ -155,6 +155,7 @@ 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); }