1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-28 06:03:25 +00:00

1. Fixed bug where global-tunnel.end() didn't clear the proxy

2. Broke infinite loop that could occur with circular referenced list
3. Added NULL check
This commit is contained in:
Bryan Roe
2022-06-23 01:33:03 -07:00
parent 4a2f9b009a
commit 36681dbbf8
3 changed files with 47 additions and 14 deletions

View File

@@ -125,18 +125,21 @@ void Duktape_RunOnEventLoop_AbortSink(void *chain, void *user)
void Duktape_RunOnEventLoop_Sink(void *chain, void *user)
{
Duktape_EventLoopDispatchData *tmp = (Duktape_EventLoopDispatchData*)user;
if (duk_ctx_is_alive(tmp->ctx) && duk_ctx_is_valid(tmp->nonce, tmp->ctx))
if (tmp != NULL)
{
// duk_context matches the intended context
if (tmp->handler != NULL) { tmp->handler(chain, tmp->user); }
if (duk_ctx_is_alive(tmp->ctx) && duk_ctx_is_valid(tmp->nonce, tmp->ctx))
{
// duk_context matches the intended context
if (tmp->handler != NULL) { tmp->handler(chain, tmp->user); }
}
else
{
// duk_context does not match the intended context
Duktape_RunOnEventLoop_AbortSink(chain, user);
return;
}
ILibMemory_Free(tmp);
}
else
{
// duk_context does not match the intended context
Duktape_RunOnEventLoop_AbortSink(chain, user);
return;
}
ILibMemory_Free(tmp);
}
#ifdef WIN32
void __stdcall Duktape_RunOnEventLoop_SanityCheck(ULONG_PTR u)

View File

@@ -1898,8 +1898,16 @@ void ILibDuktape_net_PUSH_net(duk_context *ctx, void *chain)
}
duk_ret_t ILibDuktape_globalTunnel_end(duk_context *ctx)
{
duk_push_heap_stash(ctx);
duk_del_prop_string(ctx, -1, ILibDuktape_GlobalTunnel_Stash);
ILibDuktape_globalTunnel_data *data;
ILibHashtable tmp;
duk_push_this(ctx);
duk_get_prop_string(ctx, -1, ILibDuktape_GlobalTunnel_DataPtr);
data = (ILibDuktape_globalTunnel_data*)Duktape_GetBuffer(ctx, -1, NULL);
tmp = data->exceptionsTable;
ILibHashtable_Clear(tmp);
memset(data, 0, sizeof(ILibDuktape_globalTunnel_data));
data->exceptionsTable = tmp;
return 0;
}
duk_ret_t ILibDuktape_globalTunnel_initialize(duk_context *ctx)