]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: make partitions reference counting more robust [coverity scan]
authorKarel Zak <kzak@redhat.com>
Wed, 15 May 2019 14:28:31 +0000 (16:28 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 15 May 2019 14:28:31 +0000 (16:28 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/partitions/partitions.c

index 299454765ea0fdb624ad85443133edda40e839e6..f12638e76488669754acb70378dcb92bd1022916 100644 (file)
@@ -313,13 +313,16 @@ static void blkid_probe_set_partlist(blkid_probe pr, blkid_partlist ls)
 
 static void ref_parttable(blkid_parttable tab)
 {
-       tab->nparts++;
+       if (tab)
+               tab->nparts++;
 }
 
 static void unref_parttable(blkid_parttable tab)
 {
-       tab->nparts--;
+       if (!tab)
+               return;
 
+       tab->nparts--;
        if (tab->nparts <= 0) {
                list_del(&tab->t_tabs);
                free(tab);