Xi: avoid memory leak when hitting bounds check for barrier events

The fix for CVE-2026-93519 added a bounds check for barrier events in
CreatePointerBarrierClient() and if it's hit immediately returns
BadAlloc.  Unfortunately it was added after `ret` was already allocated
and before *client_out is set to `ret`, so `ret` leaks.

This fix changes it to jump to the same cleanup code to free(ret)
that the rest of the function already uses.

Fixes: 1f42cc1f0 ("Xi: add bounds check for barrier events in input_constrain_cursor")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2352>
(cherry picked from commit 8e901e6013)
This commit is contained in:
Alan Coopersmith 2026-10-08 17:17:20 -07:00 • committed by Enrico Weigelt
commit f58dbbd64b

View file

@ -604,8 +604,10 @@ CreatePointerBarrierClient(ClientPtr client,
* function */
xorg_list_for_each_entry(counter, &cs->barriers, entry) {
nbarriers++;
if (nbarriers >= 32)
return BadAlloc;
if (nbarriers >= 32) {
err = BadAlloc;
goto error;
}
}
ret->pScreen = pScreen;