aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--swaynag/config.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/swaynag/config.c b/swaynag/config.c
index 5ff00bdb..ac5f31c0 100644
--- a/swaynag/config.c
+++ b/swaynag/config.c
@@ -422,24 +422,17 @@ int swaynag_load_config(char *path, struct swaynag *swaynag, list_t *types) {
422 422
423 if (line[0] == '[') { 423 if (line[0] == '[') {
424 char *close = strchr(line, ']'); 424 char *close = strchr(line, ']');
425 if (!close) { 425 if (!close || close != &line[nread - 2] || nread <= 3) {
426 fprintf(stderr, "Closing bracket not found on line %d\n", 426 fprintf(stderr, "Line %d is malformed\n", line_number);
427 line_number);
428 result = 1; 427 result = 1;
429 break; 428 break;
430 } 429 }
431 char *name = calloc(1, close - line); 430 *close = '\0';
432 if (!name) { 431 type = swaynag_type_get(types, &line[1]);
433 perror("calloc");
434 return EXIT_FAILURE;
435 }
436 strncat(name, line + 1, close - line - 1);
437 type = swaynag_type_get(types, name);
438 if (!type) { 432 if (!type) {
439 type = swaynag_type_new(name); 433 type = swaynag_type_new(&line[1]);
440 list_add(types, type); 434 list_add(types, type);
441 } 435 }
442 free(name);
443 } else { 436 } else {
444 char *flag = malloc(nread + 3); 437 char *flag = malloc(nread + 3);
445 if (!flag) { 438 if (!flag) {