]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fs/squashfs: sqfs_size: fix dangling pointer dirs->entry
authorRichard Genoud <richard.genoud@posteo.net>
Tue, 3 Nov 2020 11:11:09 +0000 (12:11 +0100)
committerTom Rini <trini@konsulko.com>
Thu, 19 Nov 2020 14:45:49 +0000 (09:45 -0500)
dirs->entry shouldn't be left dangling as it could be freed twice.

Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
fs/squashfs/sqfs.c

index 7da2e09cc3653dd6a93a55d4237201e647140a3e..3b008b5235c30adf07481212d496df0b832045d9 100644 (file)
@@ -1569,6 +1569,7 @@ int sqfs_size(const char *filename, loff_t *size)
                if (!ret)
                        break;
                free(dirs->entry);
+               dirs->entry = NULL;
        }
 
        if (ret) {
@@ -1582,6 +1583,7 @@ int sqfs_size(const char *filename, loff_t *size)
        ipos = sqfs_find_inode(dirs->inode_table, i_number, sblk->inodes,
                               sblk->block_size);
        free(dirs->entry);
+       dirs->entry = NULL;
 
        base = (struct squashfs_base_inode *)ipos;
        switch (get_unaligned_le16(&base->inode_type)) {