From f80ac75d0e6e6e7481d61cdb86e5a741a442f100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 26 Jul 2017 23:42:10 -0300 Subject: qcow2: fix null pointer dereference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Reviewed-by: Eric Blake Signed-off-by: Michael Tokarev --- block/qcow2-refcount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'block/qcow2-refcount.c') diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index c9b0dcb4f3..168fc32e7b 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -2189,6 +2189,8 @@ write_refblocks: * 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; @@ -2258,8 +2260,6 @@ write_refblocks: 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]); } -- cgit v1.2.1