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:
@@ -149,6 +149,7 @@ bool wm_xr_events_handle(wmWindowManager *wm)
|
|||||||
wmXrRuntimeData *wm_xr_runtime_data_create(void)
|
wmXrRuntimeData *wm_xr_runtime_data_create(void)
|
||||||
{
|
{
|
||||||
wmXrRuntimeData *runtime = MEM_callocN(sizeof(*runtime), __func__);
|
wmXrRuntimeData *runtime = MEM_callocN(sizeof(*runtime), __func__);
|
||||||
|
runtime->actactionmap = runtime->selactionmap = -1;
|
||||||
return runtime;
|
return runtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,7 @@ XrActionMapItem *WM_xr_actionmap_item_new(XrActionMap *actionmap,
|
|||||||
if (ami_prev) {
|
if (ami_prev) {
|
||||||
WM_xr_actionmap_item_ensure_unique(actionmap, ami);
|
WM_xr_actionmap_item_ensure_unique(actionmap, ami);
|
||||||
}
|
}
|
||||||
|
ami->selbinding = -1;
|
||||||
|
|
||||||
BLI_addtail(&actionmap->items, ami);
|
BLI_addtail(&actionmap->items, ami);
|
||||||
|
|
||||||
@@ -398,6 +399,7 @@ XrActionMap *WM_xr_actionmap_new(wmXrRuntimeData *runtime, const char *name, boo
|
|||||||
if (am_prev) {
|
if (am_prev) {
|
||||||
WM_xr_actionmap_ensure_unique(runtime, am);
|
WM_xr_actionmap_ensure_unique(runtime, am);
|
||||||
}
|
}
|
||||||
|
am->selitem = -1;
|
||||||
|
|
||||||
BLI_addtail(&runtime->actionmaps, am);
|
BLI_addtail(&runtime->actionmaps, am);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user