]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-util: make path_compare() accept NULL
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Jun 2021 09:05:43 +0000 (11:05 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Jul 2021 11:56:06 +0000 (13:56 +0200)
src/basic/path-util.c

index e5afb5f5f5e0de1fd258783e672b9b44fe294d40..4aebb6541ea153c6832fd445881cffb225fca9e4 100644 (file)
@@ -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.