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

Fixed edge case crash when calling response.end() with a buffer

This commit is contained in:
Bryan Roe
2020-04-03 18:23:42 -07:00
parent 7dbfae9bea
commit e89274c835

View File

@@ -191,6 +191,8 @@ int ILibDuktape_Headers_IsChunkSupported(ILibHTTPPacket *header)
}
void ILibDuktape_serverResponse_resetHttpStream(duk_context *ctx, void *serverResponse)
{
duk_idx_t t = duk_get_top(ctx);
// Need to reset HttpStream
duk_push_heapptr(ctx, serverResponse); // [serverResponse]
duk_get_prop_string(ctx, -1, ILibDuktape_SR2HttpStream); // [serverResponse][httpStream]
@@ -204,7 +206,7 @@ void ILibDuktape_serverResponse_resetHttpStream(duk_context *ctx, void *serverRe
data->bodyStream = NULL;
}
duk_pop_n(ctx, 3); // ...
duk_set_top(ctx, t);
}
void ILibDuktape_Digest_CalculateNonce(duk_context *ctx, void *heapptr, long long expiration, char *opaque, int opaqueLen, char* buffer)
{
@@ -3136,6 +3138,8 @@ void ILibDuktape_HttpStream_OnReceive(ILibWebClient_StateObject WebStateObject,
if (header->Directive == NULL && data->connectionCloseSpecified == 0)
{
duk_push_heapptr(ctx, data->DS->ParentObject); // [httpStream]
if (duk_has_prop_string(ctx, -1, ILibDuktape_HTTPStream2Socket))
{
duk_get_prop_string(ctx, -1, ILibDuktape_HTTPStream2Socket); // [httpStream][socket]
if (duk_has_prop_string(ctx, -1, ILibDuktape_Socket2Agent))
{
@@ -3147,6 +3151,15 @@ void ILibDuktape_HttpStream_OnReceive(ILibWebClient_StateObject WebStateObject,
duk_pop(ctx); // [httpStream][socket]
duk_pop_2(ctx); // ...
}
else
{
duk_pop_2(ctx);
}
}
else
{
duk_pop(ctx);
}
}
}