summaryrefslogtreecommitdiff
path: root/sway/input.c
diff options
context:
space:
mode:
authorDrew DeVault <[email protected]>2016-12-17 13:23:44 -0500
committerGitHub <[email protected]>2016-12-17 13:23:44 -0500
commitf04ee0e68d885d7e1101cc88f9a9337202041f1f (patch)
treefa4dc296a5f1377867752d320ceef4e4b0178bbf /sway/input.c
parent6c0fc2093641868df28c4087902a040f7fae05d4 (diff)
parentd859f825d3612492678f5cd6cc6dc1f2647929e1 (diff)
Merge pull request #995 from SirCmpwn/memory-use
Handle allocation failures
Diffstat (limited to 'sway/input.c')
-rw-r--r--sway/input.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sway/input.c b/sway/input.c
index acd69a6b..249d95c6 100644
--- a/sway/input.c
+++ b/sway/input.c
@@ -11,8 +11,16 @@
struct input_config *new_input_config(const char* identifier) {
struct input_config *input = calloc(1, sizeof(struct input_config));
+ if (!input) {
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
sway_log(L_DEBUG, "new_input_config(%s)", identifier);
- input->identifier = strdup(identifier);
+ if (!(input->identifier = strdup(identifier))) {
+ free(input);
+ sway_log(L_DEBUG, "Unable to allocate input config");
+ return NULL;
+ }
input->tap = INT_MIN;
input->drag_lock = INT_MIN;
@@ -45,6 +53,10 @@ char *libinput_dev_unique_id(struct libinput_device *device) {
int len = strlen(name) + sizeof(char) * 6;
char *identifier = malloc(len);
+ if (!identifier) {
+ sway_log(L_ERROR, "Unable to allocate unique input device name");
+ return NULL;
+ }
const char *fmt = "%d:%d:%s";
snprintf(identifier, len, fmt, vendor, product, name);