basic/unit-file: make sure we don't call streq() on NULL

add_names is called in two places, with fragment_basename=NULL in one of them.
gcc warns that it can be NULL.

Fixes #23646.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-06-07 11:22:08 +02:00
parent 5fb225615b
commit 6c279977e3
+1
View 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);