浏览代码

GPU OpenXR: Fix zero-length copy (#16112)

Evan Hemsley 1 月之前
父节点
当前提交
eeb832d8a1
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/gpu/xr/SDL_gpu_openxr.c

+ 3 - 1
src/gpu/xr/SDL_gpu_openxr.c

@@ -115,7 +115,9 @@ XrResult SDL_OPENXR_INTERNAL_GPUInitOpenXR(
 
     // allocate enough space for the validation layer + the user's api layers
     const char **apiLayerNames = SDL_stack_alloc(const char *, userApiLayerCount + 1);
-    SDL_memcpy((void *)apiLayerNames, userApiLayerNames, sizeof(const char *) * (userApiLayerCount));
+    if (userApiLayerCount > 0) {
+        SDL_memcpy((void *)apiLayerNames, userApiLayerNames, sizeof(const char *) * userApiLayerCount);
+    }
     apiLayerNames[userApiLayerCount] = VALIDATION_LAYER_API_NAME;
 
     // On Android, we need an extra extension for android_create_instance