[PATCH] jscript: Allocate non-temporary storage for statement lists which persist after parsing.

Paul Gofman pgofman at codeweavers.com
Fri Jul 30 06:23:39 CDT 2021


Or maybe we should better change the structures and return the statement
chain itself instead of list structure?

On 7/30/21 02:36, Paul Gofman wrote:
> Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
> ---
>     new_statement_list() uses parser_alloc_tmp() and the memory for statement list may get freed
>     in script_parse() thus making compile_function() use the freed memory.
>
>  dlls/jscript/parser.y | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/dlls/jscript/parser.y b/dlls/jscript/parser.y
> index 9fc7ea61dc3..4bad7e326db 100644
> --- a/dlls/jscript/parser.y
> +++ b/dlls/jscript/parser.y
> @@ -249,7 +249,17 @@ static expression_t *new_prop_and_value_expression(parser_ctx_t*,property_list_t
>  
>  /* ECMA-262 10th Edition    15.1 */
>  Script
> -       : ScriptBody HtmlComment { ctx->source = $1; }
> +       : ScriptBody HtmlComment {
> +                                    if ($1)
> +                                    {
> +                                        ctx->source = parser_alloc(ctx, sizeof(*ctx->source));
> +                                        *ctx->source = *$1;
> +                                    }
> +                                    else
> +                                    {
> +                                        ctx->source = NULL;
> +                                    }
> +                                }
>  




More information about the wine-devel mailing list