st/oxr: Validate xrSuggestInteractionProfileBindings better

This commit is contained in:
Jakob Bornecrantz 2020-05-31 13:50:26 +01:00
parent 6ff4b23a76
commit f4fadc6f55
2 changed files with 29 additions and 4 deletions

View file

@ -0,0 +1,2 @@
OpenXR: Validate the arguments for `xrSuggestInteractionProfileBindings` better
so that it follows the spec better.

View file

@ -7,8 +7,6 @@
* @ingroup oxr_api
*/
#include <stdio.h>
#include "oxr_objects.h"
#include "oxr_logger.h"
#include "oxr_handle.h"
@ -18,6 +16,9 @@
#include "oxr_api_funcs.h"
#include "oxr_api_verify.h"
#include <stdio.h>
#include <inttypes.h>
/*
*
@ -98,12 +99,34 @@ oxr_xrSuggestInteractionProfileBindings(
&log, suggestedBindings,
XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING);
if (suggestedBindings->countSuggestedBindings == 0) {
return oxr_error(&log, XR_ERROR_VALIDATION_FAILURE,
"(suggestedBindings->countSuggestedBindings "
"== 0) can not suggest 0 bindings");
}
for (size_t i = 0; i < suggestedBindings->countSuggestedBindings; i++) {
const XrActionSuggestedBinding *s =
&suggestedBindings->suggestedBindings[i];
struct oxr_action *dummy;
OXR_VERIFY_ACTION_NOT_NULL(&log, s->action, dummy);
struct oxr_action *act;
OXR_VERIFY_ACTION_NOT_NULL(&log, s->action, act);
if (act->act_set->attached) {
return oxr_error(
&log, XR_ERROR_ACTIONSETS_ALREADY_ATTACHED,
"(suggestedBindings->suggestedBindings[%zu]->"
"action) action '%s/%s' has already been attached",
i, act->act_set->name, act->name);
}
if (!oxr_path_is_valid(&log, inst, s->binding)) {
return oxr_error(
&log, XR_ERROR_PATH_INVALID,
"(suggestedBindings->suggestedBindings[%zu]->"
"binding == %" PRIu64 ") is not a valid path",
i, s->binding);
}
//! @todo verify path (s->binding).
}