Module: vkd3d
Branch: master
Commit: c9af34ab285e40ae3285ccfd93d63a9470333b30
URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/c9af34ab285e40ae3285ccfd93d63…
Author: Victor Chiletto <vchiletto(a)codeweavers.com>
Date: Mon May 6 07:53:14 2024 -0300
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);
}