Skip to content

Commit

Permalink
[tint][ir][val] Check access type exists before dereferencing
Browse files Browse the repository at this point in the history
Fixes: 376084082
Change-Id: Ic264d30585789ac5ecf097f233f7568a61bf1dcc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212935
Reviewed-by: dan sinclair <[email protected]>
Commit-Queue: Ryan Harrison <[email protected]>
Auto-Submit: Ryan Harrison <[email protected]>
  • Loading branch information
zoddicus authored and Dawn LUCI CQ committed Oct 29, 2024
1 parent 6dd31e2 commit ebdd6ad
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/tint/lang/core/ir/validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2383,8 +2383,9 @@ void Validator::CheckAccess(const Access* a) {
};

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;
}

Expand All @@ -2397,7 +2398,7 @@ void Validator::CheckAccess(const Access* a) {

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>();
Expand Down

0 comments on commit ebdd6ad

Please sign in to comment.