diff --git a/NEWS b/NEWS index cab2abd6d01..92cb48f0dec 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ PHP NEWS - Core: . Fixed oss-fuzz #60011 (Mis-compilation of by-reference nullsafe operator). (ilutov) + . Fixed line number of JMP instruction over else block. (ilutov) - Date: . Fixed bug GH-11368 (Date modify returns invalid datetime). (Derick) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ba203cbe2e2..3aee5af1081 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5420,6 +5420,9 @@ static void zend_compile_if(zend_ast *ast) /* {{{ */ zend_compile_stmt(stmt_ast); if (i != list->children - 1) { + /* Set the lineno of JMP to the position of the if keyword, as we don't want to + * report the last line in the if branch as covered if it hasn't actually executed. */ + CG(zend_lineno) = elem_ast->lineno; jmp_opnums[i] = zend_emit_jump(0); } zend_update_jump_target_to_next(opnum_jmpz);