aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDi Ma <focus64@gmail.com>2020-03-22 16:18:29 -0700
committerBrian Ashworth <bosrsf04@gmail.com>2020-04-14 19:41:30 -0400
commit2bece94b9bf2cf099d2f166808385ce8a7940476 (patch)
treeca2e752f8ec4d1e6a5943df659edcc64a96fd98a
parentc1c2fe04bbdab8380db62cd3b481356abea2facd (diff)
Fix a use-after-free error in switch binding
-rw-r--r--sway/commands/bind.c1
-rw-r--r--sway/input/switch.c3
2 files changed, 2 insertions, 2 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index 4e49982a..de2e7bd4 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -608,6 +608,7 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding)
return;
}
memcpy(deferred, binding, sizeof(struct sway_binding));
+ deferred->command = strdup(binding->command);
list_add(seat->deferred_bindings, deferred);
return;
}
diff --git a/sway/input/switch.c b/sway/input/switch.c
index 3bbc636d..b7c28df1 100644
--- a/sway/input/switch.c
+++ b/sway/input/switch.c
@@ -1,4 +1,3 @@
-#define _POSIX_C_SOURCE 200809L
#include "sway/config.h"
#include "sway/desktop/transaction.h"
#include "sway/input/switch.h"
@@ -57,7 +56,7 @@ static void execute_binding(struct sway_switch *sway_switch) {
calloc(1, sizeof(struct sway_binding));
dummy_binding->type = BINDING_SWITCH;
dummy_binding->flags = matched_binding->flags;
- dummy_binding->command = strdup(matched_binding->command);
+ dummy_binding->command = matched_binding->command;
seat_execute_command(seat, dummy_binding);
free(dummy_binding);