From 9ae9460bd09b6216cad14c0130b0951626d8b671 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 6 Mar 2014 13:32:26 +0400 Subject: [PATCH 1/2] Fixed refcounting --- main/output.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/output.c b/main/output.c index 8e98e3c54f..6504954593 100644 --- a/main/output.c +++ b/main/output.c @@ -495,7 +495,7 @@ PHPAPI php_output_handler *php_output_handler_create_user(zval *output_handler, user = ecalloc(1, sizeof(php_output_handler_user_func_t)); if (SUCCESS == zend_fcall_info_init(output_handler, 0, &user->fci, &user->fcc, &handler_name, &error TSRMLS_CC)) { handler = php_output_handler_init(handler_name->val, handler_name->len, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_USER TSRMLS_CC); - Z_ADDREF_P(output_handler); + if (Z_REFCOUNTED_P(output_handler)) Z_ADDREF_P(output_handler); user->zoh = output_handler; handler->func.user = user; } else { From 8d2fb9d479bf13381d67e400e3b8c7aa28d7a480 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 6 Mar 2014 13:32:43 +0400 Subject: [PATCH 2/2] Internal functions may return (e.g. on wrong arguments) keeping the original return_value. So we have to initialize return_value as IS_NULL. --- Zend/zend_execute_API.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index fb214dba10..7ddb526421 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -932,7 +932,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS EG(opline_ptr) = original_opline_ptr; } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0; -//??? ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr); + ZVAL_NULL(fci->retval); if (EX(function_state).function->common.scope) { EG(scope) = EX(function_state).function->common.scope; }