From c9af34ab285e40ae3285ccfd93d63a9470333b30 Mon Sep 17 00:00:00 2001 From: Victor Chiletto Date: Mon, 6 May 2024 07:53:14 -0300 Subject: [PATCH] vkd3d-shader/hlsl: Avoid a null pointer dereference in hlsl_block_cleanup (UBSan). destroy_block() is called with a NULL block from: * create_loop, through the loop rules for while and do-while loops. * The selection_statement rule, in the case $6.else_block is NULL. * free_parse_initializer. --- libs/vkd3d-shader/hlsl.y | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 79317bb0..c6b6219e 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -168,6 +168,9 @@ static struct list *make_empty_list(struct hlsl_ctx *ctx) static void destroy_block(struct hlsl_block *block) { + if (!block) + return; + hlsl_block_cleanup(block); vkd3d_free(block); }