mirror of
https://github.com/Ylianst/MeshAgent
synced 2026-01-09 12:03:41 +00:00
1. Fixed crash that occurs when meshcore is cleared, if FDSNAPSHOT was used
2. Fixed uncaught exception that occurs when you emit an event on a finalized object
This commit is contained in:
@@ -2403,9 +2403,16 @@ duk_ret_t ILibDuktape_ChainViewer_getSnapshot(duk_context *ctx)
|
||||
ILibForceUnBlockChain(duk_ctx_chain(ctx));
|
||||
return(1);
|
||||
}
|
||||
duk_ret_t ILibDutkape_ChainViewer_cleanup(duk_context *ctx)
|
||||
{
|
||||
duk_push_current_function(ctx);
|
||||
void *link = Duktape_GetPointerProperty(ctx, -1, "pointer");
|
||||
ILibChain_SafeRemove(duk_ctx_chain(ctx), link);
|
||||
return(0);
|
||||
}
|
||||
void ILibDuktape_ChainViewer_Push(duk_context *ctx, void *chain)
|
||||
{
|
||||
duk_push_object(ctx); // [viewer]
|
||||
duk_push_object(ctx); // [viewer]
|
||||
|
||||
ILibTransport *t = (ILibTransport*)ILibChain_Link_Allocate(sizeof(ILibTransport), 2*sizeof(void*));
|
||||
t->ChainLink.MetaData = "ILibDuktape_ChainViewer";
|
||||
@@ -2417,6 +2424,11 @@ void ILibDuktape_ChainViewer_Push(duk_context *ctx, void *chain)
|
||||
ILibDuktape_CreateInstanceMethod(ctx, "getSnapshot", ILibDuktape_ChainViewer_getSnapshot, 0);
|
||||
duk_push_array(ctx); duk_put_prop_string(ctx, -2, ILibDuktape_ChainViewer_PromiseList);
|
||||
ILibPrependToChain(chain, (void*)t);
|
||||
|
||||
duk_push_heapptr(ctx, ILibDuktape_GetProcessObject(ctx)); // [viewer][process]
|
||||
duk_events_setup_on(ctx, -1, "exit", ILibDutkape_ChainViewer_cleanup); // [viewer][process][on][this][exit][func]
|
||||
duk_push_pointer(ctx, t); duk_put_prop_string(ctx, -2, "pointer");
|
||||
duk_pcall_method(ctx, 2); duk_pop_2(ctx); // [viewer]
|
||||
}
|
||||
|
||||
duk_ret_t ILibDuktape_httpHeaders(duk_context *ctx)
|
||||
|
||||
@@ -217,6 +217,8 @@ duk_ret_t ILibDuktape_EventEmitter_emit(duk_context *ctx)
|
||||
duk_push_this(ctx); // [object]
|
||||
|
||||
ILibDuktape_EventEmitter *data = (ILibDuktape_EventEmitter*)Duktape_GetBufferProperty(ctx, -1, ILibDuktape_EventEmitter_Data);
|
||||
if (!ILibMemory_CanaryOK(data)) { return(0); } // This object has been finalized already, so we need to abort
|
||||
|
||||
char *objid = Duktape_GetStringPropertyValue(ctx, -1, ILibDuktape_OBJID, "unknown");
|
||||
duk_push_heapptr(ctx, data->retValTable); // [object][retTable]
|
||||
duk_push_heapptr(ctx, data->table); // [object][retTable][table]
|
||||
@@ -539,7 +541,8 @@ duk_ret_t ILibDuktape_EventEmitter_EmbeddedFinalizer(duk_context *ctx)
|
||||
sem_destroy(&(data->listenerCountTableLock));
|
||||
|
||||
// We need to clear the Native Dispatcher, while destroying the Hashtable
|
||||
memset(data, 0, sizeof(ILibDuktape_EventEmitter));
|
||||
|
||||
memset(ILibMemory_RawPtr(data), 0, ILibMemory_RawSize(data));
|
||||
return(0);
|
||||
}
|
||||
duk_ret_t ILibDuktape_EventEmitter_emitReturnValue(duk_context *ctx)
|
||||
|
||||
Reference in New Issue
Block a user