Hi, Il 25/09/21 14:09, Matteo Bruni ha scritto:
+ | NEW_IDENTIFIER + { + if (ctx->in_state_block) + { + struct hlsl_ir_load *load; + struct hlsl_ir_var *var; + + if (!(var = hlsl_new_var(ctx, $1, ctx->builtin_types.scalar[HLSL_TYPE_INT], @1, NULL, 0, NULL))) + YYABORT; + if (!(load = hlsl_new_var_load(ctx, var, @1))) + YYABORT; + if (!($$ = make_list(ctx, &load->node))) + { + hlsl_free_instr(&load->node); + YYABORT; + } + } This leaks var on error.
Also, the node is doubly freed in the error path (because make_list already frees the node when it fails). Maybe the outer hlsl_free_instr was meant to free the variable instead (though the variable must also be freed when hlsl_new_var_load fails). That said, I didn't know about this strange HLSL feature, so I don't know what the intended behavior would be. Does anybody have a link? Searching for "hlsl state block" didn't help much. Thanks, Giovanni.