From 8f9659554013d570fe9ff3d8a3de4175ff0f69a4 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 10 May 2021 16:06:51 +0000 Subject: [PATCH] ExternalTextureTransform: Fix undefined behavior WGSL now supports type inferencing with `let` declarations, so `var->type()` may return nullptr. Calling a method (`Is()`) on a nullptr object is UB. Instead used the free-function form which can handle nullptr objects. Change-Id: I8faf875e1550eac1306ad731a65f3662bc4e5b43 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50307 Auto-Submit: Ben Clayton Kokoro: Kokoro Reviewed-by: Brandon Jones Commit-Queue: Ben Clayton --- src/transform/external_texture_transform.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transform/external_texture_transform.cc b/src/transform/external_texture_transform.cc index eade354475..e3c61ff1ad 100644 --- a/src/transform/external_texture_transform.cc +++ b/src/transform/external_texture_transform.cc @@ -28,7 +28,7 @@ Output ExternalTextureTransform::Run(const Program* in, const DataMap&) { // Scan the AST nodes for external texture declarations. for (auto* node : ctx.src->ASTNodes().Objects()) { if (auto* var = node->As()) { - if (var->type()->Is()) { + if (Is(var->type())) { // Replace a single-plane external texture with a 2D, f32 sampled // texture. auto newType = ctx.dst->ty.sampled_texture(ast::TextureDimension::k2d,