From 3da796810bd37e0038fcbbc71b20dcb862ae8eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 8 Dec 2020 19:36:18 +0100 Subject: [PATCH] =?UTF-8?q?module/i3:=20take=20lock=20while=20updating=20?= =?UTF-8?q?=E2=80=98mode=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/i3.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/i3.c b/modules/i3.c index 89083ce..c6975fb 100644 --- a/modules/i3.c +++ b/modules/i3.c @@ -474,9 +474,14 @@ handle_mode_event(int type, const struct json_object *json, void *_mod) } const char *current_mode = json_object_get_string(change); - free(m->mode); - m->mode = strdup(current_mode); - m->dirty = true; + + mtx_lock(&mod->lock); + { + free(m->mode); + m->mode = strdup(current_mode); + m->dirty = true; + } + mtx_unlock(&mod->lock); return true; }