From 066c17585214eb705d2f48b56b864c2f5a2164b0 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 24 Nov 2021 00:08:28 +0000 Subject: [PATCH] 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 Reviewed-by: Austin Eng Reviewed-by: James Price Commit-Queue: James Price Kokoro: Kokoro --- src/writer/hlsl/generator_impl.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index 1a24ed2138..5cc4ecc603 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -186,9 +186,10 @@ SanitizedResult Sanitize( SanitizedResult result; result.program = std::move(out.program); - result.used_array_length_from_uniform_indices = - std::move(out.data.Get() - ->used_size_indices); + if (auto* res = out.data.Get()) { + result.used_array_length_from_uniform_indices = + std::move(res->used_size_indices); + } return result; }