From: Nikita Popov Date: Tue, 26 Aug 2014 17:39:40 +0000 (+0200) Subject: Don't alloc empty jmp opnum list for single-branch if X-Git-Tag: PRE_PHP7_REMOVALS~297 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c71ab607ffe7139cf01ecd0a49f1e40ca9f71da2;p=php Don't alloc empty jmp opnum list for single-branch if --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 5e2455960b..15edc7c380 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4897,7 +4897,11 @@ void zend_compile_foreach(zend_ast *ast TSRMLS_DC) { void zend_compile_if(zend_ast *ast TSRMLS_DC) { zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; - uint32_t *jmp_opnums = safe_emalloc(sizeof(uint32_t), list->children - 1, 0); + uint32_t *jmp_opnums; + + if (list->children > 1) { + jmp_opnums = safe_emalloc(sizeof(uint32_t), list->children - 1, 0); + } for (i = 0; i < list->children; ++i) { zend_ast *elem_ast = list->child[i]; @@ -4922,11 +4926,12 @@ void zend_compile_if(zend_ast *ast TSRMLS_DC) { } } - for (i = 0; i < list->children - 1; ++i) { - zend_update_jump_target_to_next(jmp_opnums[i] TSRMLS_CC); + if (list->children > 1) { + for (i = 0; i < list->children - 1; ++i) { + zend_update_jump_target_to_next(jmp_opnums[i] TSRMLS_CC); + } + efree(jmp_opnums); } - - efree(jmp_opnums); } void zend_compile_switch(zend_ast *ast TSRMLS_DC) {