From: Dmitry Stogov Date: Mon, 24 Feb 2014 12:35:55 +0000 (+0400) Subject: Fixed create_function() X-Git-Tag: POST_PHPNG_MERGE~412^2~554 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=789eb6dfc3aa524bf66c49b0677857baea90388a;p=php Fixed create_function() --- diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index d421fd927e..4595e52112 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1772,22 +1772,22 @@ ZEND_FUNCTION(create_function) efree(eval_name); if (retval==SUCCESS) { - zend_function *new_function, *func; + zend_op_array *new_function, *func; func = zend_hash_str_find_ptr(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1); if (!func) { zend_error(E_ERROR, "Unexpected inconsistency in create_function()"); RETURN_FALSE; } - new_function = pemalloc(sizeof(zend_function), func->type == ZEND_INTERNAL_FUNCTION); - memcpy(new_function, func, sizeof(zend_function)); + new_function = emalloc(sizeof(zend_op_array)); + memcpy(new_function, func, sizeof(zend_op_array)); function_add_ref(new_function); function_name = STR_ALLOC(sizeof("0lambda_")+MAX_LENGTH_OF_LONG, 0); function_name->val[0] = '\0'; do { - function_name->len = snprintf(function_name->val + 1, sizeof("lambda_")+MAX_LENGTH_OF_LONG, "lambda_%d", ++EG(lambda_count)); + function_name->len = snprintf(function_name->val + 1, sizeof("lambda_")+MAX_LENGTH_OF_LONG, "lambda_%d", ++EG(lambda_count)) + 1; } while (zend_hash_add_ptr(EG(function_table), function_name, new_function) == NULL); zend_hash_str_del(EG(function_table), LAMBDA_TEMP_FUNCNAME, sizeof(LAMBDA_TEMP_FUNCNAME)-1); RETURN_STR(function_name); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 28938e59da..7fb89bc046 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1179,9 +1179,7 @@ ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *s } else { retval = FAILURE; } - if (retval_ptr) { - zval_dtor(&pv); - } + zval_dtor(&pv); return retval; } /* }}} */