]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: improve partition copy on resize
authorKarel Zak <kzak@redhat.com>
Mon, 22 Jul 2019 10:09:38 +0000 (12:09 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Jul 2019 10:09:38 +0000 (12:09 +0200)
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 <kzak@redhat.com>
libfdisk/src/partition.c

index 55ce1ca5cce38fe9a104b1b4f4fe65a8f37c7081..80a43ffde52c5ca26d36a61f7fdeeb01d9e7e6a1 100644 (file)
@@ -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)