From: zhuwei <zhuwei@sangfor.com.cn>
Hi,
qemu_console_set_cursor() takes a reference on the QEMUCursor passed to it
and stores that reference in QemuGraphicConsole.cursor. The reference is
dropped and re-taken on every cursor update, but nothing releases the last
one: qemu_graphic_console_finalize() only drops the reference held on
c->device and leaves c->cursor untouched.
Consequently the reference count of the QEMUCursor never reaches zero when
the console is finalized. The QEMUCursor itself and the pixel buffer it
owns stay allocated, which shows up as a leak under ASan whenever a
graphic console is created and destroyed during the lifetime of a QEMU
process (e.g. with a graphical frontend, vnc or dbus display in use).
The patch releases the reference in qemu_graphic_console_finalize() with
g_clear_pointer(&c->cursor, cursor_unref), which also NULLs the pointer.
This mirrors the existing handling of the spice display cursor in
ui/spice-display.c. No functional change beyond the refcount fix.
Signed-off-by: niming <niming@sangfor.com.cn>
Signed-off-by: zhuwei <zhuwei@sangfor.com.cn>
---
ui/console.c | 3 +++
1 file changed, 3 insertions(+)