]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: free before going out of scope [coverity scan]
authorKarel Zak <kzak@redhat.com>
Tue, 4 Oct 2016 14:03:11 +0000 (16:03 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 4 Oct 2016 14:03:11 +0000 (16:03 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/sfdisk.c

index 1f14f2c120b0f9aed83320da30be85803ca28648..d8d1a87622f4430dae7a70bb587d363561828fc0 100644 (file)
@@ -295,10 +295,12 @@ static void backup_sectors(struct sfdisk *sf,
 
                if (read_all(devfd, (char *) buf, size) != (ssize_t) size) {
                        fdisk_warn(sf->cxt, _("cannot read %s"), devname);
+                       free(buf);
                        goto fail;
                }
                if (write_all(fd, buf, size) != 0) {
                        fdisk_warn(sf->cxt, _("cannot write %s"), fname);
+                       free(buf);
                        goto fail;
                }
                free(buf);