Commit eefeec12 authored by Simon Ser's avatar Simon Ser Committed by Ryan Pavlik

oxr: check input type in oxr_swapchain_gl_enumerate_images

Don't blindly cast the input struct to XrSwapchainImageOpenGLKHR, check
that the type is XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR.
parent 3b87d518
Pipeline #76439 passed with stages
in 4 minutes and 59 seconds
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* @ingroup comp_client * @ingroup comp_client
*/ */
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include "xrt/xrt_gfx_xlib.h" #include "xrt/xrt_gfx_xlib.h"
...@@ -39,10 +40,20 @@ oxr_swapchain_gl_enumerate_images(struct oxr_logger *log, ...@@ -39,10 +40,20 @@ oxr_swapchain_gl_enumerate_images(struct oxr_logger *log,
XrSwapchainImageBaseHeader *images) XrSwapchainImageBaseHeader *images)
{ {
struct xrt_swapchain_gl *xsc = (struct xrt_swapchain_gl *)sc->swapchain; struct xrt_swapchain_gl *xsc = (struct xrt_swapchain_gl *)sc->swapchain;
assert(count > 0);
if (images[0].type != XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_KHR) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"unsupported XrSwapchainImageBaseHeader type");
}
XrSwapchainImageOpenGLKHR *gl_imgs = XrSwapchainImageOpenGLKHR *gl_imgs =
(XrSwapchainImageOpenGLKHR *)images; (XrSwapchainImageOpenGLKHR *)images;
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
if (gl_imgs[i].type != images[0].type) {
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE,
"images array contains mixed types");
}
gl_imgs[i].image = xsc->images[i]; gl_imgs[i].image = xsc->images[i];
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment