writer/hlsl: Prevent NPE on error
If the HLSL sanitizer errors, then there may be no ArrayLengthFromUniform::Result, so we check the pointer before attempting to dereference it.
Bug: chromium:1273230
Change-Id: I9575d20748720623a94ac86f45da14302b20440a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70740
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index 1a24ed2..5cc4ecc 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -186,9 +186,10 @@
SanitizedResult result;
result.program = std::move(out.program);
- result.used_array_length_from_uniform_indices =
- std::move(out.data.Get<transform::ArrayLengthFromUniform::Result>()
- ->used_size_indices);
+ if (auto* res = out.data.Get<transform::ArrayLengthFromUniform::Result>()) {
+ result.used_array_length_from_uniform_indices =
+ std::move(res->used_size_indices);
+ }
return result;
}