summaryrefslogtreecommitdiff
path: root/conf.c
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2011-07-19 19:37:21 +0200
committerJoel Rosdahl <joel@rosdahl.net>2011-07-20 23:31:38 +0200
commit8e1b069308515630546311630283ef7ff5885bd1 (patch)
tree5594ab8bbc90dcd2ce0636903b8164993cef70ba /conf.c
parentb7830887ea34488b339c18ad89b49af085f4635a (diff)
downloadccache-8e1b069308515630546311630283ef7ff5885bd1.tar.gz
config: Free output from parse_line correctly
Diffstat (limited to 'conf.c')
-rw-r--r--conf.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/conf.c b/conf.c
index 383b1a80..0e80a636 100644
--- a/conf.c
+++ b/conf.c
@@ -320,11 +320,12 @@ parse_line(const char *line, char **key, char **value, char **errmsg)
#define SKIP_WS(x) while (isspace(*x)) { ++x; }
+ *key = NULL;
+ *value = NULL;
+
p = line;
SKIP_WS(p);
if (*p == '\0' || *p == '#') {
- *key = NULL;
- *value = NULL;
return true;
}
q = p;
@@ -337,6 +338,7 @@ parse_line(const char *line, char **key, char **value, char **errmsg)
if (*p != '=') {
*errmsg = x_strdup("missing equal sign");
free(*key);
+ *key = NULL;
return false;
}
++p;
@@ -483,6 +485,8 @@ conf_read(struct conf *conf, const char *path, char **errmsg)
if (ok && key) { /* key == NULL if comment or blank line */
ok = handle_conf_setting(conf, key, value, &errmsg2, false, false);
}
+ free(key);
+ free(value);
if (!ok) {
*errmsg = format("%s:%u: %s", path, line_number, errmsg2);
free(errmsg2);
@@ -586,6 +590,8 @@ conf_set_value_in_file(const char *path, const char *key, const char *value,
} else {
fputs(buf, outfile);
}
+ free(key2);
+ free(value2);
}
if (!found) {