X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Finstall.c;h=e957c333442b1828274959ad1eac5f6c8516a325;hb=7de80bfe2e61d5818601ccfddbadad3b7703ed70;hp=a2f84f893e43255f7ce674d2f6e09fc1a193eb9a;hpb=6d314eca15f6cbda38d82774b210f784d3d4f52a;p=elogind.git diff --git a/src/shared/install.c b/src/shared/install.c index a2f84f893..e957c3334 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -88,13 +88,16 @@ static int get_config_path(UnitFileScope scope, bool runtime, const char *root_d case UNIT_FILE_SYSTEM: - if (root_dir && runtime) - asprintf(&p, "%s/run/systemd/system", root_dir); - else if (runtime) + if (root_dir && runtime) { + if (asprintf(&p, "%s/run/systemd/system", root_dir) < 0) + return -ENOMEM; + } else if (runtime) p = strdup("/run/systemd/system"); - else if (root_dir) - asprintf(&p, "%s/%s", root_dir, SYSTEM_CONFIG_UNIT_PATH); - else + else if (root_dir) { + if (asprintf(&p, "%s/%s", root_dir, + SYSTEM_CONFIG_UNIT_PATH) < 0) + return -ENOMEM; + } else p = strdup(SYSTEM_CONFIG_UNIT_PATH); break;