From 89debac8f6ffbff573abbb5395a7924cea217e4c Mon Sep 17 00:00:00 2001 From: Ico Doornekamp Date: Fri, 19 May 2023 20:00:59 +0200 Subject: [PATCH] Fixed janet_loop1_impl stream use after dealloc --- src/core/ev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ev.c b/src/core/ev.c index 31b0a2f6..fd3a7b9a 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -1969,6 +1969,7 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp timeout) { JanetAsyncStatus status3 = JANET_ASYNC_STATUS_NOT_DONE; JanetAsyncStatus status4 = JANET_ASYNC_STATUS_NOT_DONE; state->event = pfd; + JanetStream *stream = state->stream; if (mask & POLLOUT) status1 = state->machine(state, JANET_ASYNC_EVENT_WRITE); if (mask & POLLIN) @@ -1983,7 +1984,6 @@ void janet_loop1_impl(int has_timeout, JanetTimestamp timeout) { status4 == JANET_ASYNC_STATUS_DONE) janet_unlisten(state, 0); /* Close the stream if requested and no more listeners are left */ - JanetStream *stream = state->stream; if ((stream->flags & JANET_STREAM_TOCLOSE) && !stream->state) { janet_stream_close(stream); }