com php-src: Don't alloc empty jmp opnum list for single-branch if: Zend/zend_compile.c

From: Date: Tue, 26 Aug 2014 20:31:57 +0000
Subject: com php-src: Don't alloc empty jmp opnum list for single-branch if: Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-81131@lists.php.net to get a copy of this message
Commit: c71ab607ffe7139cf01ecd0a49f1e40ca9f71da2 Author: Nikita Popov <nikic@php.net> Tue, 26 Aug 2014 19:39:40 +0200 Parents: cd8bbfa149e83174b44e0633866ce504f736eb97 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c71ab607ffe7139cf01ecd0a49f1e40ca9f71da2 Log: Don't alloc empty jmp opnum list for single-branch if Changed paths: M Zend/zend_compile.c Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 5e24559..15edc7c 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) {

« previous php.cvs (#81131) next »