]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: make new_partition() more robust
authorKarel Zak <kzak@redhat.com>
Fri, 18 Apr 2014 10:01:42 +0000 (12:01 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 18 Apr 2014 10:01:42 +0000 (12:01 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/partitions/partitions.c

index 37cc0c2c9f3be779e8a3c3fe21178a492ce992f4..43f0d3e33e56794ab7bd5de526a9356b4ae6110b 100644 (file)
@@ -431,10 +431,11 @@ static blkid_partition new_partition(blkid_partlist ls, blkid_parttable tab)
                /* Linux kernel has DISK_MAX_PARTS=256, but it's too much for
                 * generic Linux machine -- let start with 32 partititions.
                 */
-               ls->parts = realloc(ls->parts, (ls->nparts_max + 32) *
+               void *tmp = realloc(ls->parts, (ls->nparts_max + 32) *
                                        sizeof(struct blkid_struct_partition));
-               if (!ls->parts)
+               if (!tmp)
                        return NULL;
+               ls->parts = tmp;
                ls->nparts_max += 32;
        }