]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
chase: add two more assertions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 21 Jul 2023 02:07:01 +0000 (11:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 12:58:30 +0000 (21:58 +0900)
When 'need_absolute' is true, 'done' should always contain "/" at the
beginning, and thus should not be NULL.

src/basic/chase.c

index e66070b5d11b2062fd9e65df2763ff236a74e4e0..4d883e18d8eb62754337e7c2b0184249b822a017 100644 (file)
@@ -449,6 +449,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int
                 }
 
                 if (!done) {
+                        assert(!need_absolute || FLAGS_SET(flags, CHASE_EXTRACT_FILENAME));
                         done = strdup(append_trail_slash ? "./" : ".");
                         if (!done)
                                 return -ENOMEM;
@@ -475,6 +476,7 @@ chased_one:
                 const char *e;
 
                 if (!done) {
+                        assert(!need_absolute);
                         done = strdup(append_trail_slash ? "./" : ".");
                         if (!done)
                                 return -ENOMEM;