aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Jason Nader <jason.nader@protonmail.com>2020-03-15 17:51:10 +0900
committerLibravatar Drew DeVault <sir@cmpwn.com>2020-03-16 14:27:36 +0100
commitfcd524bb0d6f3c6cd4f2ddc180520bc56a89aa4a (patch)
tree5458da9cac517c6b97d46343990ae842d387301d
parentDocument input selector precedence (diff)
downloadsway-fcd524bb0d6f3c6cd4f2ddc180520bc56a89aa4a.tar.gz
sway-fcd524bb0d6f3c6cd4f2ddc180520bc56a89aa4a.tar.zst
sway-fcd524bb0d6f3c6cd4f2ddc180520bc56a89aa4a.zip
sway/input/cursor.c: fix undefined behaviour when event is NULL
-rw-r--r--sway/input/cursor.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index e41acd8b..3a4a69b6 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -1059,11 +1059,11 @@ uint32_t get_mouse_bindcode(const char *name, char **error) {
1059 const char *event = libevdev_event_code_get_name(EV_KEY, code); 1059 const char *event = libevdev_event_code_get_name(EV_KEY, code);
1060 if (!event || strncmp(event, "BTN_", strlen("BTN_")) != 0) { 1060 if (!event || strncmp(event, "BTN_", strlen("BTN_")) != 0) {
1061 size_t len = snprintf(NULL, 0, "Event code %d (%s) is not a button", 1061 size_t len = snprintf(NULL, 0, "Event code %d (%s) is not a button",
1062 code, event) + 1; 1062 code, event ? event : "(null)") + 1;
1063 *error = malloc(len); 1063 *error = malloc(len);
1064 if (*error) { 1064 if (*error) {
1065 snprintf(*error, len, "Event code %d (%s) is not a button", 1065 snprintf(*error, len, "Event code %d (%s) is not a button",
1066 code, event); 1066 code, event ? event : "(null)");
1067 } 1067 }
1068 return 0; 1068 return 0;
1069 } 1069 }