]> granicus.if.org Git - php/commitdiff
Fixed uninitialized var warning
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 31 May 2019 10:55:13 +0000 (12:55 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 31 May 2019 10:55:13 +0000 (12:55 +0200)
Causes build failure on release+zts azure build. I'm rewriting this
code to separate the if/else handling, because they don't really
have anything in common anyway...

Zend/zend_compile.c

index b4d4012d7f2e021c99d3487ca20348ba8fd14a49..52511aca4e049ecee338d369466f0bb4834df55b 100644 (file)
@@ -4625,21 +4625,22 @@ void zend_compile_if(zend_ast *ast) /* {{{ */
                zend_ast *cond_ast = elem_ast->child[0];
                zend_ast *stmt_ast = elem_ast->child[1];
 
-               znode cond_node;
-               uint32_t opnum_jmpz;
                if (cond_ast) {
+                       znode cond_node;
+                       uint32_t opnum_jmpz;
                        zend_compile_expr(&cond_node, cond_ast);
                        opnum_jmpz = zend_emit_cond_jump(ZEND_JMPZ, &cond_node, 0);
-               }
-
-               zend_compile_stmt(stmt_ast);
 
-               if (i != list->children - 1) {
-                       jmp_opnums[i] = zend_emit_jump(0);
-               }
+                       zend_compile_stmt(stmt_ast);
 
-               if (cond_ast) {
+                       if (i != list->children - 1) {
+                               jmp_opnums[i] = zend_emit_jump(0);
+                       }
                        zend_update_jump_target_to_next(opnum_jmpz);
+               } else {
+                       /* "else" can only occur as last element. */
+                       ZEND_ASSERT(i == list->children - 1);
+                       zend_compile_stmt(stmt_ast);
                }
        }