summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
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 b8e1945..d3921d5 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;
}