diff options
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -104,6 +104,7 @@ config *parse_config(const char *filename) { config *cfg; /* Buffer of the file contents. */ char *buf = read_file(filename, &filesize); + char *tmp = buf; /* Return NULL, if the buffer wasn't allocated */ if (buf == NULL) { @@ -118,8 +119,8 @@ config *parse_config(const char *filename) { return NULL; } - while (*buf != '\0') { - char *line = get_line(&buf); + while (*tmp != '\0') { + char *line = get_line(&tmp); char *value; char *name = strtok_r(line, "=", &value); const config_opt *opt; @@ -132,5 +133,10 @@ config *parse_config(const char *filename) { config_val val = parse_option_value(opt, value); set_config_opt(cfg, opt->type, opt->offset, val); } + + free(line); } + + free(buf); + return cfg; } |