From: Lennart Poettering Date: Fri, 27 Apr 2018 20:03:14 +0000 (+0200) Subject: nspawn: use free_and_replace() at more places X-Git-Tag: v239~305^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=10af01a5ff5a6ede9cc684def71508b88f6b93eb;p=thirdparty%2Fsystemd.git nspawn: use free_and_replace() at more places --- diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index 984fe2dc401..461c2707cf4 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -133,8 +133,7 @@ int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n) { if (!s) return log_oom(); - free(m->source); - m->source = s; + free_and_replace(m->source, s); } else { /* No source specified? In that case, use a throw-away temporary directory in /var/tmp */ @@ -165,8 +164,7 @@ int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n) { if (!s) return log_oom(); - free(*j); - *j = s; + free_and_replace(*j, s); } if (m->work_dir) { @@ -176,8 +174,7 @@ int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n) { if (!s) return log_oom(); - free(m->work_dir); - m->work_dir = s; + free_and_replace(m->work_dir, s); } else { assert(m->source);