]> git.ipfire.org Git - pakfire.git/commitdiff
path: Fix a potential memory leak if either path is not absolute
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Oct 2024 14:40:06 +0000 (14:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 22 Oct 2024 14:40:06 +0000 (14:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/path.c

index 99edf24cd3d8225df6784565f8a6c22f7269ec4b..a0262ebde8fd5067c64bc5cfc8e9227bc0d229cf 100644 (file)
@@ -446,8 +446,10 @@ int __pakfire_path_relative(char* buffer, const size_t length, const char* __roo
                goto ERROR;
 
        // Both paths must be absolute
-       if (!root->is_absolute || !path->is_absolute)
-               return -EINVAL;
+       if (!root->is_absolute || !path->is_absolute) {
+               r = -EINVAL;
+               goto ERROR;
+       }
 
        // The result is no longer absolute
        path->is_absolute = 0;