]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-util: NULL strings are definitely not valid paths
authorLennart Poettering <lennart@poettering.net>
Thu, 7 Jul 2022 21:19:12 +0000 (23:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 8 Jul 2022 09:35:00 +0000 (11:35 +0200)
Let's make this functions that check validity of paths a bit more
friendly towards one specific kind of invalid path: a NULL pointer.

This follows similar logic in path_is_valid(), path_is_normalized() and
so on.

src/basic/path-util.h

index 553aa4fb58631db69e7740634267feb838b96832..3413056b310d878e62ad6295e5d96690985d7586 100644 (file)
 #endif
 
 static inline bool is_path(const char *p) {
-        assert(p);
+        if (!p) /* A NULL pointer is definitely not a path */
+                return false;
+
         return strchr(p, '/');
 }
 
 static inline bool path_is_absolute(const char *p) {
-        assert(p);
+        if (!p) /* A NULL pointer is definitely not an absolute path */
+                return false;
+
         return p[0] == '/';
 }