summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorConnor E <38229097+c-edw@users.noreply.github.com>2019-01-18 13:45:34 +0000
committerConnor E <38229097+c-edw@users.noreply.github.com>2019-01-18 13:45:34 +0000
commit7c0ba8919712a1e23eca4b4785ab9f30f9e49a7e (patch)
treed64550b7a22a786155afc2b337a42a9393da51fc /main.c
parent291bae1e4426e698e29e31e819ebb6b2b5f02e23 (diff)
Handle alloc failures.
Diffstat (limited to 'main.c')
-rw-r--r--main.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/main.c b/main.c
index 0b97f85..000b16a 100644
--- a/main.c
+++ b/main.c
@@ -937,6 +937,12 @@ static int load_config(char *path, struct swaylock_state *state,
swaylock_log(LOG_DEBUG, "Config Line #%d: %s", line_number, line);
char *flag = malloc(nread + 3);
+ if (flag == NULL) {
+ free(line);
+ free(config);
+ swaylock_log(LOG_ERROR, "Failed to allocate memory");
+ return 0;
+ }
sprintf(flag, "--%s", line);
char *argv[] = {"swaylock", flag};
result = parse_options(2, argv, state, line_mode, NULL);