OSDN Git Service

Fix memory use after free on error paths.
authorrelan <relan@users.noreply.github.com>
Sat, 18 Jan 2014 07:35:26 +0000 (07:35 +0000)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:26:16 +0000 (08:26 +0300)
libexfat/mount.c

index 1202b4d..3606ad6 100644 (file)
@@ -218,17 +218,17 @@ int exfat_mount(struct exfat* ef, const char* spec, const char* options)
        if (ef->sb->fat_count != 1)
        {
                exfat_close(ef->dev);
-               free(ef->sb);
                exfat_error("unsupported FAT count: %hhu", ef->sb->fat_count);
+               free(ef->sb);
                return -EIO;
        }
        /* officially exFAT supports cluster size up to 32 MB */
        if ((int) ef->sb->sector_bits + (int) ef->sb->spc_bits > 25)
        {
                exfat_close(ef->dev);
-               free(ef->sb);
                exfat_error("too big cluster size: 2^%d",
                                (int) ef->sb->sector_bits + (int) ef->sb->spc_bits);
+               free(ef->sb);
                return -EIO;
        }