summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-18 08:48:41 -0500
committerGitHub <noreply@github.com>2019-01-18 08:48:41 -0500
commit63fb6c0d963a5a9e6a07a11bf9c4c7e1e8d7dcfc (patch)
treed64550b7a22a786155afc2b337a42a9393da51fc /main.c
parentaf03502384c2c8aa5c93f977a6dcd9df99af5cb3 (diff)
parent7c0ba8919712a1e23eca4b4785ab9f30f9e49a7e (diff)
Merge pull request #23 from c-edw/feature/RemoveVLAs
Remove VLAs.
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/main.c b/main.c
index 5c21817..000b16a 100644
--- a/main.c
+++ b/main.c
@@ -936,10 +936,17 @@ static int load_config(char *path, struct swaylock_state *state,
}
swaylock_log(LOG_DEBUG, "Config Line #%d: %s", line_number, line);
- char flag[nread + 3];
+ 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);
+ free(flag);
if (result != 0) {
break;
}