chiark / gitweb /
util-lib: accept invoking chase_symlinks() with a NULL return parameter
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Dec 2016 16:15:06 +0000 (17:15 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 17 Jul 2017 15:58:35 +0000 (17:58 +0200)
Let's permit invoking chase_symlinks() with a NULL return parameter. If so, the
resolved name is not returned, and call is useful for checking for existance of
a file, without actually returning its ultimate path.

src/basic/fs-util.c

index 4d494650cb916cfcd3fa697cb2884449d44f331a..471708bbea8f85ba939d4b313befea2cc2cbc87c 100644 (file)
@@ -813,8 +813,10 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
                         return -ENOMEM;
         }
 
-        *ret = done;
-        done = NULL;
+        if (ret) {
+                *ret = done;
+                done = NULL;
+        }
 
         return exists;
 }