[PATCH vkd3d 5/8] vkd3d-shader/hlsl: Check argument count for constructors.
Zebediah Figura
zfigura at codeweavers.com
Thu Apr 28 13:21:35 CDT 2022
On 4/28/22 08:32, Giovanni Mascellani wrote:
> Based on a patch by Francisco Casas.
>
> Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
> ---
> libs/vkd3d-shader/hlsl.y | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
> index e7fe74d8..3fff8fc6 100644
> --- a/libs/vkd3d-shader/hlsl.y
> +++ b/libs/vkd3d-shader/hlsl.y
> @@ -2044,12 +2044,20 @@ static struct list *add_call(struct hlsl_ctx *ctx, const char *name,
> static struct list *add_constructor(struct hlsl_ctx *ctx, struct hlsl_type *type,
> struct parse_initializer *params, struct vkd3d_shader_location loc)
> {
> + unsigned int size = initializer_size(params);
> static unsigned int counter;
> struct hlsl_ir_load *load;
> struct hlsl_ir_var *var;
> unsigned int i, idx = 0;
> char name[23];
>
> + if (hlsl_type_component_count(type) != size)
> + {
> + hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT,
> + "Expected %u components in constructor, but got %u.", hlsl_type_component_count(type), size);
> + return NULL;
> + }
> +
> sprintf(name, "<constructor-%x>", counter++);
> if (!(var = hlsl_new_synthetic_var(ctx, name, type, loc)))
> return NULL;
We already handle this in the caller.
More information about the wine-devel
mailing list