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>
This commit is contained in:
Ben Clayton 2021-11-24 00:08:28 +00:00 committed by Tint LUCI CQ
parent fb3c1c4d4b
commit 066c175852
1 changed files with 4 additions and 3 deletions

View File

@ -186,9 +186,10 @@ SanitizedResult Sanitize(
SanitizedResult result;
result.program = std::move(out.program);
if (auto* res = out.data.Get<transform::ArrayLengthFromUniform::Result>()) {
result.used_array_length_from_uniform_indices =
std::move(out.data.Get<transform::ArrayLengthFromUniform::Result>()
->used_size_indices);
std::move(res->used_size_indices);
}
return result;
}