From dfb38509898881af408c80d97904a2736d495931 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Mon, 2 Jan 2023 11:05:55 +0100
Subject: [PATCH 1/1] fix reload binding memory issue: copy
 current_binding_mode

---
 src/bindings.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/bindings.c b/src/bindings.c
index 4cb916fa..2c8d5970 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -845,7 +845,7 @@ CommandResult *run_binding(Binding *bind, Con *con) {
     Binding *bind_cp = binding_copy(bind);
     /* The "mode" command might change the current mode, so back it up to
      * correctly produce an event later. */
-    const char *modename = current_binding_mode;
+    char *modename = sstrdup(current_binding_mode);
 
     CommandResult *result = parse_command(command, NULL, NULL);
     free(command);
@@ -873,6 +873,7 @@ CommandResult *run_binding(Binding *bind, Con *con) {
     }
 
     ipc_send_binding_event("run", bind_cp, modename);
+    FREE(modename);
     binding_free(bind_cp);
 
     return result;
-- 
2.20.1

