Francisco Casas : vkd3d-shader/hlsl: Handle errors in recursive calls in hlsl_type_clone().

Alexandre Julliard julliard at winehq.org
Mon Jul 18 15:37:45 CDT 2022


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

Author: Francisco Casas <fcasas at codeweavers.com>
Date:   Thu Jul 14 21:23:44 2022 -0400

vkd3d-shader/hlsl: Handle errors in recursive calls in hlsl_type_clone().

Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d-shader/hlsl.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index b349eb15..eac58c69 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -505,7 +505,12 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
     switch (old->type)
     {
         case HLSL_CLASS_ARRAY:
-            type->e.array.type = hlsl_type_clone(ctx, old->e.array.type, default_majority, modifiers);
+            if (!(type->e.array.type = hlsl_type_clone(ctx, old->e.array.type, default_majority, modifiers)))
+            {
+                vkd3d_free((void *)type->name);
+                vkd3d_free(type);
+                return NULL;
+            }
             type->e.array.elements_count = old->e.array.elements_count;
             break;
 
@@ -528,7 +533,13 @@ struct hlsl_type *hlsl_type_clone(struct hlsl_ctx *ctx, struct hlsl_type *old,
                 struct hlsl_struct_field *dst_field = &type->e.record.fields[i];
 
                 dst_field->loc = src_field->loc;
-                dst_field->type = hlsl_type_clone(ctx, src_field->type, default_majority, modifiers);
+                if (!(dst_field->type = hlsl_type_clone(ctx, src_field->type, default_majority, modifiers)))
+                {
+                    vkd3d_free(type->e.record.fields);
+                    vkd3d_free((void *)type->name);
+                    vkd3d_free(type);
+                    return NULL;
+                }
                 dst_field->name = hlsl_strdup(ctx, src_field->name);
                 if (src_field->semantic.name)
                 {




More information about the wine-cvs mailing list