From d07dfb11c29172df12f8c86213e8c1488aa2d527 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 9 Jan 2013 13:58:56 +1000 Subject: [PATCH] xfree86: don't access the old input handler after freeing it Introduced in 323869f3298cbbfe864af9404a8aed1bf7995d79 Signed-off-by: Peter Hutterer Reviewed-by: Dave Airlie (cherry picked from commit f4a58469a298c226668fd8dce375bf22331c902d) --- hw/xfree86/common/xf86Events.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index 9e5336183..7e80fa922 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -619,14 +619,16 @@ InputHandlerProc xf86SetConsoleHandler(InputHandlerProc proc, pointer data) { static IHPtr handler = NULL; - IHPtr old_handler = handler; + InputHandlerProc old_proc = NULL; - if (old_handler) - xf86RemoveGeneralHandler(old_handler); + if (handler) { + old_proc = handler->ihproc; + xf86RemoveGeneralHandler(handler); + } handler = xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); - return (old_handler) ? old_handler->ihproc : NULL; + return old_proc; } static void