1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-24 04:04:31 +00:00

Fixed potential crash

This commit is contained in:
Bryan Roe
2021-02-18 01:49:07 -08:00
parent 4116bafb17
commit b8e4ba48b4

View File

@@ -504,9 +504,10 @@ int ILibDuktape_readableStream_WriteEnd(ILibDuktape_readableStream *stream)
if (ILibDuktape_EventEmitter_HasListeners(stream->emitter, "end") != 0)
{
duk_context *xx = stream->ctx;
ILibDuktape_EventEmitter_SetupEmit(stream->ctx, stream->object, "end"); // [emit][this][end]
if (duk_pcall_method(stream->ctx, 1) != 0) { ILibDuktape_Process_UncaughtException(stream->ctx); }
duk_pop(stream->ctx); // ...
duk_pop(xx); // ...
retVal = 0;
}
}
@@ -522,11 +523,14 @@ void ILibDuktape_readableStream_Closed(ILibDuktape_readableStream *stream)
duk_pop(stream->ctx); // ...
}
duk_push_heapptr(stream->ctx, stream->object); // [stream]
duk_get_prop_string(stream->ctx, -1, "unpipe"); // [stream][unpipe]
duk_swap_top(stream->ctx, -2); // [unpipe][this]
if (duk_pcall_method(stream->ctx, 0) != 0) { ILibDuktape_Process_UncaughtException(stream->ctx); }
duk_pop(stream->ctx); // ...
if (ILibMemory_CanaryOK(stream))
{
duk_push_heapptr(stream->ctx, stream->object); // [stream]
duk_get_prop_string(stream->ctx, -1, "unpipe"); // [stream][unpipe]
duk_swap_top(stream->ctx, -2); // [unpipe][this]
if (duk_pcall_method(stream->ctx, 0) != 0) { ILibDuktape_Process_UncaughtException(stream->ctx); }
duk_pop(stream->ctx); // ...
}
}
duk_ret_t ILibDuktape_readableStream_pause(duk_context *ctx)