xkb: ensure XkbAllocNames sets num_rg to 0 on allocation failure

If there was a previous radio_groups array which we failed to realloc
and freed instead, clear the array size in the XkbNamesRec.

Taken from xorg/lib/libx11@258a8ced681dc1bc50396be7439fce23f9807e2a

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
(cherry picked from commit 09c6f09eb7)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1894>
This commit is contained in:
Alan Coopersmith 2025-02-22 10:02:20 -08:00 committed by Olivier Fourdan
parent f71114570f
commit 1e52c5c094

View file

@ -194,8 +194,10 @@ XkbAllocNames(XkbDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases)
free(prev_radio_groups);
}
}
if (names->radio_groups == NULL)
if (names->radio_groups == NULL) {
names->num_rg = 0;
return BadAlloc;
}
names->num_rg = nTotalRG;
}
return Success;