summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block/qcow2-refcount.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index fa78e46ee..465d5d36e 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -402,6 +402,10 @@ static int write_refcount_block_entries(BDRVQcowState *s,
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);