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