]> git.ipfire.org Git - thirdparty/grub.git/commit
gfxmenu/gui_image: Fix double free of bitmap
authorAlec Brown <alec.r.brown@oracle.com>
Wed, 13 Dec 2023 22:25:13 +0000 (22:25 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 14 Dec 2023 18:29:34 +0000 (19:29 +0100)
commit7c8ae7dcbd59a963130a7aaae7a7348334465f74
treeeef6de7b481af4cbfcb9ba9f960c539d79ebdfc3
parent63fc253fc9f148c09d5bb38971edcb50dc090f9d
gfxmenu/gui_image: Fix double free of bitmap

In grub-core/gfxmenu/gui_image.c, Coverity detected a double free in the
function load_image(). The function checks if self->bitmap and self->raw_bitmap
aren't NULL and then frees them. In the case self->bitmap and self->raw_bitmap
are the same, only self->raw_bitmap is freed which would also free the memory
used by self->bitmap. However, in this case self->bitmap isn't being set to NULL
which could lead to a double free later in the code. After self->raw_bitmap is
freed, it gets set to the variable bitmap. If this variable is NULL, the code
could have a path that would free self->bitmap a second time in the function
rescale_image().

Fixes: CID 292472
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/gfxmenu/gui_image.c