qcow2-bitmap: fix bitmap_free

Fix possible crash on error path in
qcow2_remove_persistent_dirty_bitmap. Although bitmap_free was added in
88ddffae8f the bug was introduced later in commit 469c71edc7 (when
qcow2_remove_persistent_dirty_bitmap was added).

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 20170714123341.373857-1-vsementsov@virtuozzo.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Vladimir Sementsov-Ogievskiy 2017-07-14 15:33:41 +03:00 committed by Max Reitz
parent 0696ae2c92
commit b6b75a99da
1 changed files with 4 additions and 0 deletions

View File

@ -487,6 +487,10 @@ static inline void bitmap_directory_to_be(uint8_t *dir, size_t size)
static void bitmap_free(Qcow2Bitmap *bm)
{
if (bm == NULL) {
return;
}
g_free(bm->name);
g_free(bm);
}