Skip to content

Commit

Permalink
qcow2: fix null pointer dereference
Browse files Browse the repository at this point in the history
It seems this assert() was somehow misplaced.

block/qcow2-refcount.c:2193:42: warning: Array access (from variable 'on_disk_reftable') results in a null pointer dereference
        on_disk_reftable[refblock_index] = refblock_offset;
        ~~~~~~~~~~~~~~~~                 ^

Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
philmd authored and Michael Tokarev committed Jul 31, 2017
1 parent b7b1e9d commit f80ac75
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/qcow2-refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,8 @@ static int rebuild_refcount_structure(BlockDriverState *bs,
* this will leak that range, but we can easily fix that by running
* a leak-fixing check after this rebuild operation */
reftable_offset = -1;
} else {
assert(on_disk_reftable);
}
on_disk_reftable[refblock_index] = refblock_offset;

Expand Down Expand Up @@ -2258,8 +2260,6 @@ static int rebuild_refcount_structure(BlockDriverState *bs,
goto write_refblocks;
}

assert(on_disk_reftable);

for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) {
cpu_to_be64s(&on_disk_reftable[refblock_index]);
}
Expand Down

0 comments on commit f80ac75

Please sign in to comment.