]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: fix potential memory leaks
authorKarel Zak <kzak@redhat.com>
Mon, 13 Jan 2025 10:26:06 +0000 (11:26 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Jan 2025 10:26:06 +0000 (11:26 +0100)
Addresses: https://github.com/util-linux/util-linux/pull/3356
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/save.c

index 1a617c072e7dda179e38063c8db745b5930bda31..295924e15a8367b82137b3111b081fd678a56bf3 100644 (file)
@@ -109,7 +109,8 @@ int blkid_flush_cache(blkid_cache cache)
                    && errno != EEXIST) {
                        DBG(SAVE, ul_debug("can't create %s directory for cache file",
                                        BLKID_RUNTIME_DIR));
-                       return 0;
+                       ret = 0;
+                       goto done;
                }
        }
 
@@ -117,7 +118,8 @@ int blkid_flush_cache(blkid_cache cache)
        if (((ret = stat(filename, &st)) < 0 && errno != ENOENT) ||
            (ret == 0 && access(filename, W_OK) < 0)) {
                DBG(SAVE, ul_debug("can't write to cache file %s", filename));
-               return 0;
+               ret = 0;
+               goto done;
        }
 
        /*
@@ -154,7 +156,7 @@ int blkid_flush_cache(blkid_cache cache)
 
        if (!file) {
                ret = errno;
-               goto errout;
+               goto done;
        }
 
        list_for_each(p, &cache->bic_devs) {
@@ -201,7 +203,7 @@ int blkid_flush_cache(blkid_cache cache)
                }
        }
 
-errout:
+done:
        free(tmp);
        if (filename != cache->bic_filename)
                free(filename);