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:
commit
b965427b59
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user