summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorEvgeny Vereshchagin <evvers@ya.ru>2017-02-22 04:02:57 +0300
committerGitHub <noreply@github.com>2017-02-22 04:02:57 +0300
commitb965427b59a6912a46e1cdb26b732d3ea396b332 (patch)
tree710ebc7fae2727a95ea5c17bc49b066b851dd0c7 /src/basic
parent05f426d2b80cefc171fc7756bb92df8373f8145a (diff)
parent1d046f57207d6af02ba07c79b5c96eb267e61bc9 (diff)
Merge pull request #5409 from keszybz/test-env-util-memleak
test-env-util: fix typo leading to memleak
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/env-util.c2
-rw-r--r--src/basic/fileio.c16
2 files changed, 10 insertions, 8 deletions
diff --git a/src/basic/env-util.c b/src/basic/env-util.c
index 2ca64c3301..1ec574e8a0 100644
--- a/src/basic/env-util.c
+++ b/src/basic/env-util.c
@@ -637,7 +637,7 @@ char *replace_env_n(const char *format, size_t n, char **env, unsigned flags) {
break;
nest--;
- if (nest == 0) { // || !strchr(e+1, '}')) {
+ if (nest == 0) {
const char *t;
_cleanup_free_ char *v = NULL;
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index b9a9f74892..7c2c2b38f5 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -554,13 +554,14 @@ static int parse_env_file_internal(
}
}
- if (state == PRE_VALUE ||
- state == VALUE ||
- state == VALUE_ESCAPE ||
- state == SINGLE_QUOTE_VALUE ||
- state == SINGLE_QUOTE_VALUE_ESCAPE ||
- state == DOUBLE_QUOTE_VALUE ||
- state == DOUBLE_QUOTE_VALUE_ESCAPE) {
+ if (IN_SET(state,
+ PRE_VALUE,
+ VALUE,
+ VALUE_ESCAPE,
+ SINGLE_QUOTE_VALUE,
+ SINGLE_QUOTE_VALUE_ESCAPE,
+ DOUBLE_QUOTE_VALUE,
+ DOUBLE_QUOTE_VALUE_ESCAPE)) {
key[n_key] = 0;
@@ -780,6 +781,7 @@ static int merge_env_file_push(
if (!env_name_is_valid(key)) {
log_error("%s:%u: invalid variable name \"%s\", ignoring.", strna(filename), line, key);
+ free(value);
return 0;
}