diff --git a/lib/core/context.c b/lib/core/context.c index af818ebe3..c12b21611 100644 --- a/lib/core/context.c +++ b/lib/core/context.c @@ -609,6 +609,12 @@ lws_create_context(const struct lws_context_creation_info *info) goto early_bail; } +#if defined(LWS_WITH_SYS_STATE) + // NOTE: we need to init this fields because they may be used in logger when context destroying + context->mgr_system.state_names = system_state_names; + context->mgr_system.context = context; +#endif + #if defined(LWS_WITH_NETWORK) context->event_loop_ops = plev->ops; context->us_wait_resolution = us_wait_resolution; @@ -1340,11 +1346,9 @@ lws_create_context(const struct lws_context_creation_info *info) * init the lws_state mgr for the system state */ - context->mgr_system.state_names = system_state_names; context->mgr_system.name = "system"; context->mgr_system.state = LWS_SYSTATE_CONTEXT_CREATED; context->mgr_system.parent = context; - context->mgr_system.context = context; #if defined(LWS_WITH_SYS_SMD) context->mgr_system.smd_class = LWSSMDCL_SYSTEM_STATE; #endif