xkb: Fix key type without level names in XkbCopyKeymap

A key type that has no level names is legit. Before this commit,
`XkbCopyKeymap` would make such level inconsistent by setting its
number of levels to 0 while keeping its map entries. It suffices
to clear the names array.

Fixed by copying the level count from the source type.

WARNING: this will trigger an error in `XkbGetNames`, which worked
before this commit only by chance. This is fixed in the next commit.

(cherry picked from commit 12605989af)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
This commit is contained in:
Pierre Le Marre 2025-10-15 23:53:24 +02:00 committed by Marge Bot
parent d2f1d74f6c
commit bdc7eb8f07

View file

@ -1047,7 +1047,7 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (dtype->num_levels && dtype->level_names &&
i < dst->map->num_types)
free(dtype->level_names);
dtype->num_levels = 0;
dtype->num_levels = stype->num_levels;
dtype->level_names = NULL;
}