From 5107483cd641570e2ff6853af457364bfa8fe6ca Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sun, 7 May 2023 13:17:19 +0200 Subject: [PATCH] Correctly copy lineno for zval asts (#11203) The comment was incorrect. Zval ASTs store their lineno in u2, but u2 does not get copied in ZVAL_COPY. This triggers use-of-uninitialized errors with MSAN. Unfortunately, I don't have a simple reproducer. --- Zend/zend_ast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 6d5c5aaa446..70d01bb9f85 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -1063,8 +1063,8 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf) new->kind = ZEND_AST_ZVAL; new->attr = ast->attr; ZVAL_COPY(&new->val, zend_ast_get_zval(ast)); + Z_LINENO(new->val) = zend_ast_get_lineno(ast); buf = (void*)((char*)buf + sizeof(zend_ast_zval)); - // Lineno gets copied with ZVAL_COPY } else if (ast->kind == ZEND_AST_CONSTANT) { zend_ast_zval *new = (zend_ast_zval*)buf; new->kind = ZEND_AST_CONSTANT;