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 <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-07-22 12:09:38 +02:00
parent 1768d77c18
commit 10c39f03a1
1 changed files with 6 additions and 0 deletions

View 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)