From: Karel Zak Date: Fri, 18 Apr 2014 10:01:42 +0000 (+0200) Subject: libblkid: make new_partition() more robust X-Git-Tag: v2.25-rc1~267 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a2c2dab26ce500832ce3d426f1be57d7e1e370f;p=thirdparty%2Futil-linux.git libblkid: make new_partition() more robust Signed-off-by: Karel Zak --- diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c index 37cc0c2c9f..43f0d3e33e 100644 --- a/libblkid/src/partitions/partitions.c +++ b/libblkid/src/partitions/partitions.c @@ -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; }