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.
This commit is contained in:
Peter Hutterer 2007-06-29 11:56:18 +09:30
parent f7f3fe7fe7
commit 2691c05fd6

View File

@ -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))