]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
basic/unit-file: make sure we don't call streq() on NULL
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 7 Jun 2022 08:50:42 +0000 (10:50 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 7 Jun 2022 09:22:08 +0000 (11:22 +0200)
add_names is called in two places, with fragment_basename=NULL in one of them.
gcc warns that it can be NULL.

Fixes #23646.

src/basic/unit-file.c

index 83c29bb25f821b4f1eb844a854333ac26efb067c..ac0236d6357ebbf721dc8a2fde1cd1a05b1c6eef 100644 (file)
@@ -689,6 +689,7 @@ static int add_names(
                                 return log_debug_errno(r, "Cannot find instance fragment %s: %m", inst);
 
                         if (inst_fragment &&
+                            fragment_basename &&
                             !streq(basename(inst_fragment), fragment_basename)) {
                                 log_debug("Instance %s has fragment %s and is not an alias of %s.",
                                           inst, inst_fragment, unit_name);