From 2691c05fd647d9fa10f791ac397ecb9c423a076f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 29 Jun 2007 11:56:18 +0930 Subject: Make sure window->optional is allocated before assigning it. DeletePassiveGrabFromList() may remove the window optional, so we need to re-alloc it if it isn't there anymore. Thanks to Colin Harrison for spotting the bug. --- dix/grabs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dix/grabs.c b/dix/grabs.c index cecd7ec39..2210cd05e 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -322,12 +322,6 @@ AddPassiveGrabToList(GrabPtr pGrab) } } - if (!pGrab->window->optional && !MakeWindowOptional (pGrab->window)) - { - FreeGrab(pGrab); - return BadAlloc; - } - /* Remove all grabs that match the new one exactly */ for (grab = wPassiveGrabs(pGrab->window); grab; grab = grab->next) { @@ -338,6 +332,12 @@ AddPassiveGrabToList(GrabPtr pGrab) } } + if (!pGrab->window->optional && !MakeWindowOptional (pGrab->window)) + { + FreeGrab(pGrab); + return BadAlloc; + } + pGrab->next = pGrab->window->optional->passiveGrabs; pGrab->window->optional->passiveGrabs = pGrab; if (AddResource(pGrab->resource, RT_PASSIVEGRAB, (pointer)pGrab)) -- cgit v1.2.3