From 78220ed07e2df39fb7a9a8736f46f2a520ff0c6f Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Thu, 7 Sep 2023 11:30:22 +0200 Subject: [PATCH] vkd3d-shader/tpf: Destroy the SM4 parser on parsing errors. --- libs/vkd3d-shader/tpf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index f1a6def4..5bf72fb2 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -2642,9 +2642,16 @@ int vkd3d_shader_sm4_parser_create(const struct vkd3d_shader_compile_info *compi if (sm4->p.shader_version.type == VKD3D_SHADER_TYPE_HULL && !sm4->has_control_point_phase && !sm4->p.failed) shader_sm4_validate_default_phase_index_ranges(sm4); + if (sm4->p.failed) + { + WARN("Failed to parse shader.\n"); + shader_sm4_destroy(&sm4->p); + return VKD3D_ERROR_INVALID_SHADER; + } + *parser = &sm4->p; - return sm4->p.failed ? VKD3D_ERROR_INVALID_SHADER : VKD3D_OK; + return VKD3D_OK; } static void write_sm4_block(const struct tpf_writer *tpf, const struct hlsl_block *block);