diff options
| -rw-r--r-- | comet.conf | 2 | ||||
| -rw-r--r-- | src/config.c | 13 | ||||
| -rw-r--r-- | src/util.c | 11 | ||||
| -rw-r--r-- | src/util.h | 2 |
4 files changed, 24 insertions, 4 deletions
@@ -6,7 +6,7 @@ height = 40 background = #abc - blocks = date, perf, try2, sus + blocks = date, perf, try2 [jib] sus = false diff --git a/src/config.c b/src/config.c index c9543b7..3f7da08 100644 --- a/src/config.c +++ b/src/config.c @@ -223,11 +223,13 @@ static bool config_read_list(const char *value, char ***result) *end = '\0'; if (!config_read_string(token, &list[n++])) { + free(copy); free(list); return false; } } + free(copy); list[n] = NULL; *result = list; return true; @@ -568,24 +570,29 @@ bool config_resolve_children(config_t *config, block_t *block) if (!strcmp(children[i], config->blocks[j]->label)) { if (config->blocks[j]->resolved) { log_error("Block '%s' can only be referenced by one block", config->blocks[j]->label); - return false; + goto error; } log_debug("Block '%s' is parent of '%s'", block->label, config->blocks[j]->label); group->children[i] = config->blocks[j]; if (!config_resolve_children(config, config->blocks[j])) - return false; + goto error; goto next; } } log_error("Block '%s' not found", children[i]); - return false; + goto error; next: } + strfree(children); return true; + +error: + strfree(children); + return false; } block_t *config_resolve(config_t *config) @@ -205,3 +205,14 @@ next: buffer[n] = '\0'; return buffer; } + +void strfree(char **list) +{ + if (list == NULL) + return; + + for (char **head = list; *head != NULL; head++) + free(*head); + + free(list); +} @@ -69,4 +69,6 @@ size_t strprefix(const char *string, const char *prefix); char *strformat(const char *string, char delim, const char *keys[], const char *values[]); +void strfree(char **list); + #endif |
