Fix invalid XR action map indices after alloc
Although the relevant structs (wmXrRuntime/XrActionMap/ XrActionMapItem) are zero-allocated, the selected and active action map indices need to be initialized to -1 to prevent potential out-of-bounds list access.
This commit is contained in:
parent
d98791a106
commit
151eed752b
@ -149,6 +149,7 @@ bool wm_xr_events_handle(wmWindowManager *wm)
|
||||
wmXrRuntimeData *wm_xr_runtime_data_create(void)
|
||||
{
|
||||
wmXrRuntimeData *runtime = MEM_callocN(sizeof(*runtime), __func__);
|
||||
runtime->actactionmap = runtime->selactionmap = -1;
|
||||
return runtime;
|
||||
}
|
||||
|
||||
|
@ -256,6 +256,7 @@ XrActionMapItem *WM_xr_actionmap_item_new(XrActionMap *actionmap,
|
||||
if (ami_prev) {
|
||||
WM_xr_actionmap_item_ensure_unique(actionmap, ami);
|
||||
}
|
||||
ami->selbinding = -1;
|
||||
|
||||
BLI_addtail(&actionmap->items, ami);
|
||||
|
||||
@ -398,6 +399,7 @@ XrActionMap *WM_xr_actionmap_new(wmXrRuntimeData *runtime, const char *name, boo
|
||||
if (am_prev) {
|
||||
WM_xr_actionmap_ensure_unique(runtime, am);
|
||||
}
|
||||
am->selitem = -1;
|
||||
|
||||
BLI_addtail(&runtime->actionmaps, am);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user