]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount-util: call CLEANUP_ARRAY after allocating array
authorLuca Boccassi <bluca@debian.org>
Thu, 2 Nov 2023 09:34:18 +0000 (09:34 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 2 Nov 2023 15:34:10 +0000 (15:34 +0000)
Coverity gets confused if it is called before.

CID#1523757

src/shared/mount-util.c

index a7493a38147e363972a8251e9e2683bf6e2d9e1d..02640a13a9e4cecac24494986b42e16a09668931 100644 (file)
@@ -1378,12 +1378,12 @@ int remount_idmap_fd(
         int *mount_fds = NULL;
         size_t n_mounts_fds = 0;
 
-        CLEANUP_ARRAY(mount_fds, n_mounts_fds, close_many_and_free);
-
         mount_fds = new(int, n);
         if (!mount_fds)
                 return log_oom_debug();
 
+        CLEANUP_ARRAY(mount_fds, n_mounts_fds, close_many_and_free);
+
         for (size_t i = 0; i < n; i++) {
                 int mntfd;