From: Lennart Poettering Date: Wed, 17 Oct 2018 18:32:20 +0000 (+0200) Subject: core: strjoina() in a loop is never OK X-Git-Tag: v240~466^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c475e57d672e410ecd05bb8315c92a1d6cd830ca;p=thirdparty%2Fsystemd.git core: strjoina() in a loop is never OK Let's use plain strjoin() instead. --- diff --git a/src/core/manager.c b/src/core/manager.c index 6a18e970656..c4fb60984a6 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -3118,6 +3118,8 @@ int manager_serialize( fprintf(f, "log-target-override=%s\n", log_target_to_string(log_get_target())); for (q = 0; q < _MANAGER_TIMESTAMP_MAX; q++) { + _cleanup_free_ char *joined = NULL; + /* The following timestamps only apply to the host system, hence only serialize them there */ if (in_initrd() && IN_SET(q, MANAGER_TIMESTAMP_USERSPACE, MANAGER_TIMESTAMP_FINISH, @@ -3126,9 +3128,11 @@ int manager_serialize( MANAGER_TIMESTAMP_UNITS_LOAD_START, MANAGER_TIMESTAMP_UNITS_LOAD_FINISH)) continue; - t = manager_timestamp_to_string(q); - const char *field = strjoina(t, "-timestamp"); - dual_timestamp_serialize(f, field, m->timestamps + q); + joined = strjoin(manager_timestamp_to_string(q), "-timestamp"); + if (!joined) + return log_oom(); + + dual_timestamp_serialize(f, joined, m->timestamps + q); } if (!switching_root)