mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-17 04:15:44 +00:00
st/oxr: Validate view array types
This commit is contained in:
parent
7e96a1c557
commit
92f7e36083
|
@ -204,6 +204,10 @@ oxr_xrLocateViews(XrSession session,
|
|||
OXR_VERIFY_ARG_NOT_NULL(&log, views);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < viewCapacityInput; i++) {
|
||||
OXR_VERIFY_ARG_ARRAY_ELEMENT_TYPE(&log, views, i, XR_TYPE_VIEW);
|
||||
}
|
||||
|
||||
if (viewLocateInfo->displayTime <= (XrTime)0) {
|
||||
return oxr_error(&log, XR_ERROR_TIME_INVALID, "(time == %" PRIi64 ") is not a valid time.",
|
||||
viewLocateInfo->displayTime);
|
||||
|
|
|
@ -156,6 +156,10 @@ oxr_xrEnumerateViewConfigurationViews(XrInstance instance,
|
|||
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrEnumerateViewConfigurationViews");
|
||||
OXR_VERIFY_SYSTEM_AND_GET(&log, inst, systemId, sys);
|
||||
|
||||
for (uint32_t i = 0; i < viewCapacityInput; i++) {
|
||||
OXR_VERIFY_ARG_ARRAY_ELEMENT_TYPE(&log, views, i, XR_TYPE_VIEW_CONFIGURATION_VIEW);
|
||||
}
|
||||
|
||||
return oxr_system_enumerate_view_conf_views(&log, sys, viewConfigurationType, viewCapacityInput,
|
||||
viewCountOutput, views);
|
||||
}
|
||||
|
|
|
@ -140,6 +140,19 @@ extern "C" {
|
|||
OXR_VERIFY_ARG_TYPE_CAN_BE_NULL(log, arg, type_enum); \
|
||||
} while (false)
|
||||
|
||||
/*!
|
||||
* Must only be used with full typed arrays, aka non-basetyped arrays like that
|
||||
* passed into xrEnumerateSwapchainImages.
|
||||
*/
|
||||
#define OXR_VERIFY_ARG_ARRAY_ELEMENT_TYPE(log, array, index, type_enum) \
|
||||
do { \
|
||||
if ((array)[index].type != type_enum) { \
|
||||
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
|
||||
"(" #array "[%u]->type == 0x%08x) expected 0x%08x", index, \
|
||||
(array)[index].type, type_enum); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define OXR_VERIFY_SUBACTION_PATHS(log, count, paths) \
|
||||
do { \
|
||||
if (count > 0 && paths == NULL) { \
|
||||
|
|
Loading…
Reference in a new issue