1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-06 00:13:33 +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)

View File

@@ -919,7 +919,8 @@ struct ILibLifeTime
void *Reserved;
char *CurrentTriggeredMetaData;
void *DeleteList;
void *ObjectList;
int ObjectCount;
};
@@ -5218,7 +5219,7 @@ void *ILibQueue_DeQueue(ILibQueue q)
void *node;
node = ILibLinkedList_GetNode_Head((ILibLinkedList)q);
if (node!=NULL)
if (node!=NULL && ILibMemory_CanaryOK(node))
{
RetVal = ILibLinkedList_GetDataFromNode(node);
ILibLinkedList_Remove(node);
@@ -7880,6 +7881,19 @@ void ILibLifeTime_Remove(void *LifeTimeToken, void *data)
void *EventQueue;
if (UPnPLifeTime == NULL || UPnPLifeTime->ObjectList == NULL) return;
////
//// Check to see if we are on the Microstack Thread, to see if we can simplify this
////
//if (ILibIsRunningOnChainThread(UPnPLifeTime->ChainLink.ParentChain) == 0)
//{
// // Not on the right thread, so we need to defer processing to the Microstack Thread
// ILibQueue_Lock(NULL);
// ILibQueue_UnLock(NULL);
//}
EventQueue = ILibQueue_Create();
ILibLinkedList_Lock(UPnPLifeTime->ObjectList);
@@ -8194,6 +8208,14 @@ void* ILibLinkedList_GetNode_Tail(void *LinkedList)
*/
void* ILibLinkedList_GetNextNode(void *LinkedList_Node)
{
if (ILibMemory_CanaryOK(LinkedList_Node))
{
if (((struct ILibLinkedListNode*)LinkedList_Node)->Next == LinkedList_Node)
{
// There is a circular reference, so we need to break the loop
return(NULL);
}
}
return(ILibMemory_CanaryOK(LinkedList_Node) ? ((struct ILibLinkedListNode*)LinkedList_Node)->Next : NULL);
}