[tint][ir][val] Check access type exists before dereferencing
Fixes: 376084082
Change-Id: Ic264d30585789ac5ecf097f233f7568a61bf1dcc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212935
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
diff --git a/src/tint/lang/core/ir/validator.cc b/src/tint/lang/core/ir/validator.cc
index e345413..26fbe44 100644
--- a/src/tint/lang/core/ir/validator.cc
+++ b/src/tint/lang/core/ir/validator.cc
@@ -2383,8 +2383,9 @@
};
auto* index = a->Indices()[i];
- if (DAWN_UNLIKELY(!index->Type()->IsIntegerScalar())) {
- err() << "index must be integer, got " << index->Type()->FriendlyName();
+ if (DAWN_UNLIKELY(!index->Type() || !index->Type()->IsIntegerScalar())) {
+ err() << "index must be integer, got "
+ << (index->Type() ? index->Type()->FriendlyName() : "undefined");
return;
}
@@ -2397,7 +2398,7 @@
if (auto* const_index = index->As<ir::Constant>()) {
auto* value = const_index->Value();
- if (value->Type()->IsSignedIntegerScalar()) {
+ if (!value->Type() || value->Type()->IsSignedIntegerScalar()) {
// index is a signed integer scalar. Check that the index isn't negative.
// If the index is unsigned, we can skip this.
auto idx = value->ValueAs<AInt>();