xkb: fix client-triggerable memory leak in ProcXkbGetKbdByName

CHK_MASK_LEGAL expands to 'return BadValue' when the check fails and
doesn't clean up the already allocated names.keycodes, names.types, etc.

Move the check up so we don't need any cleanup code.

Co-Authored-by: Claude Code <noreply@anthropic.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2184>
This commit is contained in:
Peter Hutterer 2026-04-17 15:09:44 +10:00 committed by Marge Bot
parent 665e8a0c43
commit 0d27fbb67c

View file

@ -6025,6 +6025,9 @@ ProcXkbGetKbdByName(ClientPtr client)
if (stuff->load && dev->hasDdxKeymap)
return BadAccess;
CHK_MASK_LEGAL(0x01, stuff->want, XkbGBN_AllComponentsMask);
CHK_MASK_LEGAL(0x02, stuff->need, XkbGBN_AllComponentsMask);
xkb = dev->key->xkbInfo->desc;
status = Success;
str = (unsigned char *) &stuff[1];
@ -6055,9 +6058,6 @@ ProcXkbGetKbdByName(ClientPtr client)
return status;
}
CHK_MASK_LEGAL(0x01, stuff->want, XkbGBN_AllComponentsMask);
CHK_MASK_LEGAL(0x02, stuff->need, XkbGBN_AllComponentsMask);
if (stuff->load)
fwant = XkbGBN_AllComponentsMask;
else