Commit 79e51d6b authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Release all globals when the script is uninitialized.

Most of these globals were leaking before as they were never freed at all. Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c35e5274
......@@ -91,6 +91,17 @@ void script_release(script_ctx_t *ctx)
heap_free(ctx);
}
static void script_globals_release(script_ctx_t *ctx)
{
unsigned i;
for(i = 0; i < ARRAY_SIZE(ctx->global_objects); i++) {
if(ctx->global_objects[i]) {
jsdisp_release(ctx->global_objects[i]);
ctx->global_objects[i] = NULL;
}
}
}
static void change_state(JScript *This, SCRIPTSTATE state)
{
if(This->ctx->state == state)
......@@ -483,25 +494,7 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
This->ctx->site = NULL;
}
if(This->ctx->map_prototype) {
jsdisp_release(This->ctx->map_prototype);
This->ctx->map_prototype = NULL;
}
if(This->ctx->set_prototype) {
jsdisp_release(This->ctx->set_prototype);
This->ctx->set_prototype = NULL;
}
if(This->ctx->object_prototype) {
jsdisp_release(This->ctx->object_prototype);
This->ctx->object_prototype = NULL;
}
if(This->ctx->global) {
jsdisp_release(This->ctx->global);
This->ctx->global = NULL;
}
script_globals_release(This->ctx);
/* FALLTHROUGH */
case SCRIPTSTATE_UNINITIALIZED:
change_state(This, state);
......
......@@ -387,6 +387,8 @@ struct _script_ctx_t {
DWORD last_match_index;
DWORD last_match_length;
union {
struct {
jsdisp_t *global;
jsdisp_t *function_constr;
jsdisp_t *array_constr;
......@@ -409,7 +411,11 @@ struct _script_ctx_t {
jsdisp_t *vbarray_constr;
jsdisp_t *map_prototype;
jsdisp_t *set_prototype;
};
jsdisp_t *global_objects[22];
};
};
C_ASSERT(RTL_SIZEOF_THROUGH_FIELD(script_ctx_t, set_prototype) == RTL_SIZEOF_THROUGH_FIELD(script_ctx_t, global_objects));
void script_release(script_ctx_t*) DECLSPEC_HIDDEN;
......
......@@ -3293,7 +3293,6 @@ static void test_invokeex(void)
str = SysAllocString(L"call");
hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id);
SysFreeString(str);
todo_wine
ok(hres == E_UNEXPECTED, "GetDispID failed: %08lx\n", hres);
IDispatchEx_Release(dispex);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment