Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kim <pk15950@gmail.com>2021-08-06 11:55:00 +0300
committerPeter Kim <pk15950@gmail.com>2021-08-06 11:55:00 +0300
commit151eed752b01970fdd3cbf69405211b310b80f74 (patch)
tree2b151a4a5343cc636e88c8bdd87ae3b9f7ebf124 /source/blender/windowmanager
parentd98791a106ffd1546ec476f3f38caeedd6f99047 (diff)
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.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/xr/intern/wm_xr.c1
-rw-r--r--source/blender/windowmanager/xr/intern/wm_xr_actionmap.c2
2 files changed, 3 insertions, 0 deletions
diff --git a/source/blender/windowmanager/xr/intern/wm_xr.c b/source/blender/windowmanager/xr/intern/wm_xr.c
index 716a0936a24..3091a3a19f1 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr.c
@@ -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;
}
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c b/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c
index 7673f2aa212..f9ad34b5a9b 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c
@@ -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);