From 105396778174a39bb04e9a78281ec7601e252d9f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Jun 2021 11:05:43 +0200 Subject: [PATCH] path-util: make path_compare() accept NULL --- src/basic/path-util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/basic/path-util.c b/src/basic/path-util.c index e5afb5f5f5e..4aebb6541ea 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -466,8 +466,10 @@ char *path_startswith_full(const char *path, const char *prefix, bool accept_dot int path_compare(const char *a, const char *b) { int r; - assert(a); - assert(b); + /* Order NULL before non-NULL */ + r = CMP(!!a, !!b); + if (r != 0) + return r; /* A relative path and an absolute path must not compare as equal. * Which one is sorted before the other does not really matter. -- 2.47.3