@@ -379,11 +379,19 @@ static zval *php_dom_xpath_callback_fetch_args(xmlXPathParserContextPtr ctxt, ui
379379 return params ;
380380}
381381
382- static void php_dom_xpath_callback_cleanup_args (zval * params , uint32_t param_count )
382+ static void php_dom_xpath_callback_cleanup_args (php_dom_xpath_callbacks * xpath_callbacks , zval * params , uint32_t param_count )
383383{
384384 if (params ) {
385385 for (uint32_t i = 0 ; i < param_count ; i ++ ) {
386- zval_ptr_dtor (& params [i ]);
386+ zval * param = & params [i ];
387+ if (Z_TYPE_P (param ) == IS_OBJECT || Z_TYPE_P (param ) == IS_ARRAY ) {
388+ if (xpath_callbacks -> node_list == NULL ) {
389+ xpath_callbacks -> node_list = zend_new_array (0 );
390+ }
391+ zend_hash_next_index_insert_new (xpath_callbacks -> node_list , param );
392+ } else {
393+ zval_ptr_dtor (param );
394+ }
387395 }
388396 efree (params );
389397 }
@@ -478,7 +486,7 @@ PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_call_php_ns(php_dom_xpath_cal
478486
479487cleanup :
480488 xmlXPathFreeObject (obj );
481- php_dom_xpath_callback_cleanup_args (params , param_count );
489+ php_dom_xpath_callback_cleanup_args (xpath_callbacks , params , param_count );
482490cleanup_no_obj :
483491 if (UNEXPECTED (result != SUCCESS )) {
484492 /* Push sentinel value */
@@ -506,7 +514,7 @@ PHP_DOM_EXPORT zend_result php_dom_xpath_callbacks_call_custom_ns(php_dom_xpath_
506514
507515 zend_result result = php_dom_xpath_callback_dispatch (xpath_callbacks , ns , ctxt , params , param_count , function_name , function_name_length );
508516
509- php_dom_xpath_callback_cleanup_args (params , param_count );
517+ php_dom_xpath_callback_cleanup_args (xpath_callbacks , params , param_count );
510518 if (UNEXPECTED (result != SUCCESS )) {
511519 /* Push sentinel value */
512520 valuePush (ctxt , xmlXPathNewString ((const xmlChar * ) "" ));
0 commit comments