From 8a2c2dab26ce500832ce3d426f1be57d7e1e370f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 18 Apr 2014 12:01:42 +0200 Subject: [PATCH] libblkid: make new_partition() more robust Signed-off-by: Karel Zak --- libblkid/src/partitions/partitions.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; } -- 2.47.3