From: Karel Zak Date: Mon, 22 Jul 2019 10:09:38 +0000 (+0200) Subject: libfdisk: improve partition copy on resize X-Git-Tag: v2.35-rc1~304 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=10c39f03a1e70cf2a4b8e0301784174ac5730251;p=thirdparty%2Futil-linux.git libfdisk: improve partition copy on resize It seems pretty fragile to copy also reference counting and reference to table list. Addresses: https://github.com/karelzak/util-linux/pull/822 Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c index 55ce1ca5cc..80a43ffde5 100644 --- a/libfdisk/src/partition.c +++ b/libfdisk/src/partition.c @@ -85,7 +85,13 @@ static struct fdisk_partition *__copy_partition(struct fdisk_partition *o) if (!n) return NULL; + memcpy(n, o, sizeof(*n)); + + /* do not copy reference to lists, etc.*/ + n->refcount = 1; + INIT_LIST_HEAD(&n->parts); + if (n->type) fdisk_ref_parttype(n->type); if (o->name)