aboutsummaryrefslogtreecommitdiff
path: root/sway/input/switch.c
diff options
context:
space:
mode:
authorDi Ma <focus64@gmail.com>2020-03-22 15:21:51 -0700
committerBrian Ashworth <bosrsf04@gmail.com>2020-04-14 19:41:30 -0400
commita3e574f63ffdf34b1bc21620be3d065cee1ea54b (patch)
tree7b27eefd6aa716f627be327b94c8162804942672 /sway/input/switch.c
parentb300bace0f1da0fe19336ad8b3a70802fc49a57a (diff)
Fix a use-after-free error in switch binding
Diffstat (limited to 'sway/input/switch.c')
-rw-r--r--sway/input/switch.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sway/input/switch.c b/sway/input/switch.c
index b7c28df1..8347f066 100644
--- a/sway/input/switch.c
+++ b/sway/input/switch.c
@@ -1,8 +1,10 @@
+#define _POSIX_C_SOURCE 200809L
#include "sway/config.h"
#include "sway/desktop/transaction.h"
#include "sway/input/switch.h"
#include <wlr/types/wlr_idle.h>
#include "log.h"
+#include <string.h>
struct sway_switch *sway_switch_create(struct sway_seat *seat,
struct sway_seat_device *device) {
@@ -56,7 +58,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 = matched_binding->command;
+ dummy_binding->command = strdup(matched_binding->command);
seat_execute_command(seat, dummy_binding);
free(dummy_binding);