diff --git a/src/ssb.c b/src/ssb.c index e4d59e69..916a463c 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -1223,9 +1223,10 @@ void tf_ssb_connection_destroy(tf_ssb_connection_t* connection) } if (!JS_IsUndefined(connection->object)) { - JS_SetOpaque(connection->object, NULL); - JS_FreeValue(ssb->context, connection->object); + JSValue object = connection->object; connection->object = JS_UNDEFINED; + JS_SetOpaque(object, NULL); + JS_FreeValue(ssb->context, object); } if (connection->async.data && !uv_is_closing((uv_handle_t*)&connection->async)) {