From:             d dot stogov at turck dot spb dot ru
Operating system: Linux
PHP version:      4.3.2
PHP Bug Type:     Class/Object related
Bug description:  aggregate() doesn't increment methods' refcount

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 bug report at http://bugs.php.net/?id=24519&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24519&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24519&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24519&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24519&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24519&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24519&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24519&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24519&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24519&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24519&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24519&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24519&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24519&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24519&r=gnused

Reply via email to