From 0b03c30949a2d6327557f25fd02ea1d148e1900b Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Wed, 24 Jan 2024 16:21:37 -0800 Subject: [PATCH] Cache the Error Before Any Side Effects (#619) --- source/event_loop.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/event_loop.c b/source/event_loop.c index 5870b87e8..a6d51da66 100644 --- a/source/event_loop.c +++ b/source/event_loop.c @@ -165,12 +165,16 @@ static struct aws_event_loop_group *s_event_loop_group_new( return el_group; -on_error: +on_error:; + /* cache the error code to prevent any potential side effects */ + int cached_error_code = aws_last_error(); aws_mem_release(alloc, usable_cpus); s_aws_event_loop_group_shutdown_sync(el_group); s_event_loop_group_thread_exit(el_group); + /* raise the cached error code */ + aws_raise_error(cached_error_code); return NULL; }