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>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1821>
(cherry picked from commit 09c6f09eb7)
This commit is contained in:
Alan Coopersmith 2025-02-22 10:02:20 -08:00
parent 5f140561e1
commit e93b15196d

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;