]> git.proxmox.com Git - qemu.git/blobdiff - block/qcow2-refcount.c
qcow2: Fix corruption after error in update_refcount
[qemu.git] / block / qcow2-refcount.c
index 5b7cda47747fc5381189dd2879ff13d8de5ea3d8..22b0b45ff7af9a3cccdda70468e843fd470cd4bc 100644 (file)
@@ -417,6 +417,10 @@ static int write_refcount_block_entries(BlockDriverState *bs,
         return 0;
     }
 
+    if (first_index < 0) {
+        return 0;
+    }
+
     first_index &= ~(REFCOUNTS_PER_SECTOR - 1);
     last_index = (last_index + REFCOUNTS_PER_SECTOR)
         & ~(REFCOUNTS_PER_SECTOR - 1);