summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-01-21 19:45:56 +0100
committerGitHub <noreply@github.com>2022-01-21 19:45:56 +0100
commit03cf308c16f016c49964b343602c3fbd22415fcc (patch)
treee606805c438e9854d0c22be1e265963b4a3f543b /src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
parentMerge pull request #7695 from Morph1984/is-pow2 (diff)
parentshader_recompiler: fix potential OOB access (diff)
downloadyuzu-03cf308c16f016c49964b343602c3fbd22415fcc.tar
yuzu-03cf308c16f016c49964b343602c3fbd22415fcc.tar.gz
yuzu-03cf308c16f016c49964b343602c3fbd22415fcc.tar.bz2
yuzu-03cf308c16f016c49964b343602c3fbd22415fcc.tar.lz
yuzu-03cf308c16f016c49964b343602c3fbd22415fcc.tar.xz
yuzu-03cf308c16f016c49964b343602c3fbd22415fcc.tar.zst
yuzu-03cf308c16f016c49964b343602c3fbd22415fcc.zip
Diffstat (limited to 'src/shader_recompiler/backend/spirv/spirv_emit_context.cpp')
-rw-r--r--src/shader_recompiler/backend/spirv/spirv_emit_context.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
index d3ba66569..cd90c084a 100644
--- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp
@@ -164,9 +164,10 @@ void DefineGenericOutput(EmitContext& ctx, size_t index, std::optional<u32> invo
while (element < 4) {
const u32 remainder{4 - element};
const TransformFeedbackVarying* xfb_varying{};
- if (!ctx.runtime_info.xfb_varyings.empty()) {
- xfb_varying = &ctx.runtime_info.xfb_varyings[base_attr_index + element];
- xfb_varying = xfb_varying && xfb_varying->components > 0 ? xfb_varying : nullptr;
+ const size_t xfb_varying_index{base_attr_index + element};
+ if (xfb_varying_index < ctx.runtime_info.xfb_varyings.size()) {
+ xfb_varying = &ctx.runtime_info.xfb_varyings[xfb_varying_index];
+ xfb_varying = xfb_varying->components > 0 ? xfb_varying : nullptr;
}
const u32 num_components{xfb_varying ? xfb_varying->components : remainder};