Henri Verbeet : vkd3d-compiler: Default to VKD3D_SHADER_SOURCE_HLSL when the source size is smaller than a uint32_t.

Alexandre Julliard julliard at winehq.org
Wed Jun 22 11:32:11 CDT 2022


Module: vkd3d
Branch: master
Commit: 4093fe49bfcd201a4f62b02c73b81bfcf5055e99
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=4093fe49bfcd201a4f62b02c73b81bfcf5055e99

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Wed Jun 22 16:09:01 2022 +0200

vkd3d-compiler: Default to VKD3D_SHADER_SOURCE_HLSL when the source size is smaller than a uint32_t.

For example, when the input is an empty file. Leaving the source type as
VKD3D_SHADER_SOURCE_NONE would cause (potential) subsequent
get_source_type_info() calls to return NULL, resulting in a segmentation
fault.

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/vkd3d-compiler/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c
index ab475617..9cb90cd5 100644
--- a/programs/vkd3d-compiler/main.c
+++ b/programs/vkd3d-compiler/main.c
@@ -663,11 +663,11 @@ int main(int argc, char **argv)
     {
         uint32_t token;
 
-        if (options.preprocess_only)
+        if (options.preprocess_only || info.source.size < sizeof(token))
         {
             options.source_type = VKD3D_SHADER_SOURCE_HLSL;
         }
-        else if (info.source.size >= sizeof(token))
+        else
         {
             memcpy(&token, info.source.code, sizeof(token));
             if (token == TAG_DXBC)




More information about the wine-cvs mailing list