1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

Merge pull request #5409 from keszybz/test-env-util-memleak

test-env-util: fix typo leading to memleak
This commit is contained in:
Evgeny Vereshchagin 2017-02-22 04:02:57 +03:00 committed by GitHub
commit b965427b59
4 changed files with 13 additions and 11 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -1025,7 +1025,7 @@ static int list_devices(void) {
j = items + n++;
for (c = 0; c < _COLUMN_MAX; c++) {
const char *x;
const char *x = NULL;
size_t k;
switch (c) {

View File

@ -160,8 +160,8 @@ static void test_replace_env(bool braceless) {
q = replace_env("BARBAR=$BARBAR=${BARBAR}", (char**) env, flags);
assert_se(streq(q, braceless ? "BARBAR==" : "BARBAR=$BARBAR="));
q = replace_env("BAR=$BAR$BAR${BAR}${BAR}", (char**) env, flags);
assert_se(streq(q, braceless ? "BAR=waldowaldowaldowaldo" : "BAR=$BAR$BARwaldowaldo"));
r = replace_env("BAR=$BAR$BAR${BAR}${BAR}", (char**) env, flags);
assert_se(streq(r, braceless ? "BAR=waldowaldowaldowaldo" : "BAR=$BAR$BARwaldowaldo"));
p = replace_env("${BAR}$BAR$BAR", (char**) env, flags);
assert_se(streq(p, braceless ? "waldowaldowaldo" : "waldo$BAR$BAR"));