From: Marc-André Lureau Date: Thu, 6 Apr 2017 12:05:11 +0000 (+0200) Subject: console: add same surface replace pre-condition X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=6905b93447;p=qemu.git console: add same surface replace pre-condition Catch an invalid state early, before a potential use-after-free. This is mainly useful for documentation purposes. Signed-off-by: Marc-André Lureau Message-id: 20170406120513.638-2-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- diff --git a/ui/console.c b/ui/console.c index 419b098c11..0cbe5033dd 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1538,6 +1538,8 @@ void dpy_gfx_replace_surface(QemuConsole *con, DisplaySurface *old_surface = con->surface; DisplayChangeListener *dcl; + assert(old_surface != surface); + con->surface = surface; QLIST_FOREACH(dcl, &s->listeners, next) { if (con != (dcl->con ? dcl->con : active_console)) {