From 10c8b73075fa0dd5512cc14be7240ec47f68dece Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 15 Dec 2016 18:26:53 -0500 Subject: Handle calloc failures --- sway/input.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sway/input.c') diff --git a/sway/input.c b/sway/input.c index 61757ab8..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; -- cgit v1.2.3-54-g00ecf