[PATCH 3/3] jscript: Release all globals when the script ctx is destroyed or re-initialized.

Jacek Caban jacek at codeweavers.com
Mon May 30 13:18:55 CDT 2022


On 5/30/22 19:24, Gabriel Ivăncescu wrote:
> Most of these globals were leaking before as they were never freed at
> all. Also, they have to be freed during script ctx destruction because an
> unintialized script might still make use of them (e.g. retrieving a builtin
> function via PROPERTYGET requires ctx->function_constr to be available),
> so freeing them during state transition would crash.


I checked it (see the attached patch) and in such case function 
prototype is not really functional on Windows. This means that 
ctx->function_constr is not really needed for them. I didn't test it 
further, but I wouldn't be surprised if on Windows, all objects would be 
"detached" at this point from both ctx and prototype.


> +static inline void globals_release(script_ctx_t *ctx)
> +{
> +    jsdisp_t **iter = &ctx->function_constr, **end = &ctx->set_prototype + 1;
> +    while(iter != end) {
> +        if(*iter) {
> +            jsdisp_release(*iter);
> +            *iter = NULL;
> +        }
> +        iter++;
> +    }
> +}


That's ugly. We could potentially store those in array in the first 
place if we really need something like this. Also, there is no need for 
inline.


Thanks,

Jacek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.diff
Type: text/x-patch
Size: 595 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20220530/928dca43/attachment.bin>


More information about the wine-devel mailing list