@@ -1671,6 +1671,7 @@ void user_shutdown_function_dtor(zval *zv) /* {{{ */
1671
1671
zval_ptr_dtor (& shutdown_function_entry -> fci .params [i ]);
1672
1672
}
1673
1673
1674
+ efree (shutdown_function_entry -> fci .params );
1674
1675
efree (shutdown_function_entry );
1675
1676
}
1676
1677
/* }}} */
@@ -1762,8 +1763,7 @@ PHPAPI void php_call_shutdown_functions(void) /* {{{ */
1762
1763
if (BG (user_shutdown_function_names )) {
1763
1764
zend_try {
1764
1765
zend_hash_apply (BG (user_shutdown_function_names ), user_shutdown_function_call );
1765
- }
1766
- zend_end_try ();
1766
+ } zend_end_try ();
1767
1767
}
1768
1768
}
1769
1769
/* }}} */
@@ -1786,24 +1786,22 @@ PHPAPI void php_free_shutdown_functions(void) /* {{{ */
1786
1786
/* {{{ Register a user-level function to be called on request termination */
1787
1787
PHP_FUNCTION (register_shutdown_function )
1788
1788
{
1789
- php_shutdown_function_entry * entry = emalloc ( sizeof ( php_shutdown_function_entry )) ;
1790
- bool status = false ;
1789
+ php_shutdown_function_entry entry ;
1790
+ zval * params ;
1791
1791
1792
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "f*" , & entry -> fci , & entry -> fci_cache ,
1793
- & entry -> fci .params , & entry -> fci .param_count ) == FAILURE ) {
1794
- efree (entry );
1795
- RETURN_THROWS ();
1796
- }
1792
+ ZEND_PARSE_PARAMETERS_START (1 , -1 )
1793
+ Z_PARAM_FUNC (entry .fci , entry .fci_cache )
1794
+ Z_PARAM_VARIADIC ('+' , params , entry .fci .param_count );
1795
+ ZEND_PARSE_PARAMETERS_END ();
1797
1796
1798
- Z_TRY_ADDREF (entry -> fci .function_name );
1799
- for (size_t i = 0 ; i < entry -> fci .param_count ; i ++ ) {
1800
- Z_TRY_ADDREF (entry -> fci .params [i ]);
1801
- }
1797
+ entry .fci .params = emalloc (sizeof (zval ) * entry .fci .param_count );
1802
1798
1803
- status = append_user_shutdown_function (entry );
1804
- ZEND_ASSERT (status );
1799
+ Z_TRY_ADDREF (entry .fci .function_name );
1800
+ for (size_t i = 0 ; i < entry .fci .param_count ; i ++ ) {
1801
+ ZVAL_COPY (& entry .fci .params [i ], & params [i ]);
1802
+ }
1805
1803
1806
- efree ( entry );
1804
+ ZEND_ASSERT ( append_user_shutdown_function ( & entry ) );
1807
1805
}
1808
1806
/* }}} */
1809
1807
0 commit comments