diff options
author | Zebediah Figura <zfigura@codeweavers.com> | 2022-03-30 03:24:27 +0300 |
---|---|---|
committer | Giovanni Mascellani <gmascellani@codeweavers.com> | 2022-07-26 15:48:54 +0300 |
commit | 0024f62637c1a05395306d9ecfacf1e5d4e09963 (patch) | |
tree | eb1da233e88d165022b356544b16ba32a7bb1f2e | |
parent | ea536dbd1e9a84e21aa211f6a12f0ed65cfb6544 (diff) |
vkd3d-shader/hlsl: Fix a memory leak when declaring typedefs.
-rw-r--r-- | libs/vkd3d-shader/hlsl.y | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 5ee7ff78..a279e239 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -982,7 +982,7 @@ static bool gen_struct_fields(struct hlsl_ctx *ctx, struct parse_fields *fields, return true; } -static bool add_typedef(struct hlsl_ctx *ctx, struct hlsl_type *orig_type, struct list *list) +static void add_typedefs(struct hlsl_ctx *ctx, struct hlsl_type *orig_type, struct list *list) { struct parse_variable_def *v, *v_next; struct hlsl_type *type; @@ -1016,14 +1016,16 @@ static bool add_typedef(struct hlsl_ctx *ctx, struct hlsl_type *orig_type, struc if (!(type = hlsl_new_array_type(ctx, type, v->arrays.sizes[i]))) { free_parse_variable_def(v); - ret = false; - break; + continue; } } if (!ret) continue; vkd3d_free(v->arrays.sizes); + assert(!v->initializer.instrs); + assert(!v->semantic.name); + vkd3d_free((void *)type->name); type->name = v->name; @@ -1035,7 +1037,6 @@ static bool add_typedef(struct hlsl_ctx *ctx, struct hlsl_type *orig_type, struc vkd3d_free(v); } vkd3d_free(list); - return true; } static bool add_func_parameter(struct hlsl_ctx *ctx, struct list *list, @@ -3944,8 +3945,7 @@ typedef: hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, "Storage modifiers are not allowed on typedefs."); - if (!add_typedef(ctx, type, $4)) - YYABORT; + add_typedefs(ctx, type, $4); } type_specs: |