[PATCH vkd3d v7 1/8] vkd3d-shader/hlsl: Avoid leaks on memory allocation failures when parsing initializers.
Matteo Bruni
mbruni at codeweavers.com
Wed Mar 30 16:38:26 CDT 2022
From: Francisco Casas <fcasas at codeweavers.com>
Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
v7: Catch another case.
libs/vkd3d-shader/hlsl.y | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 1ab56fba..0fc8fa29 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -3208,7 +3208,10 @@ complex_initializer:
{
$$.args_count = 1;
if (!($$.args = hlsl_alloc(ctx, sizeof(*$$.args))))
+ {
+ destroy_instr_list($1);
YYABORT;
+ }
$$.args[0] = node_from_list($1);
$$.instrs = $1;
}
@@ -3229,15 +3232,25 @@ initializer_expr_list:
{
$$.args_count = 1;
if (!($$.args = hlsl_alloc(ctx, sizeof(*$$.args))))
+ {
+ destroy_instr_list($1);
YYABORT;
+ }
$$.args[0] = node_from_list($1);
$$.instrs = $1;
}
| initializer_expr_list ',' initializer_expr
{
+ struct hlsl_ir_node **new_args;
+
$$ = $1;
- if (!($$.args = hlsl_realloc(ctx, $$.args, ($$.args_count + 1) * sizeof(*$$.args))))
+ if (!(new_args = hlsl_realloc(ctx, $$.args, ($$.args_count + 1) * sizeof(*$$.args))))
+ {
+ free_parse_initializer(&$$);
+ destroy_instr_list($3);
YYABORT;
+ }
+ $$.args = new_args;
$$.args[$$.args_count++] = node_from_list($3);
list_move_tail($$.instrs, $3);
vkd3d_free($3);
--
2.34.1
More information about the wine-devel
mailing list