From 8bd7cc7e88d979c801d69357fc2c34db3beb6023 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 7 Apr 2021 15:32:31 +0000 Subject: [PATCH] ast::Variable: Fix nullptr access in info_to_str With type inference, declared_type_ may be null. Check it is not null before calling type_name(). Change-Id: I3b7630286b75aa9d021d9cf54eecedc3287a62f2 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/46872 Kokoro: Kokoro Reviewed-by: Antonio Maiorano Commit-Queue: Ben Clayton Auto-Submit: Ben Clayton --- src/ast/variable.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ast/variable.cc b/src/ast/variable.cc index 793cb974ad..3c7d5a0d92 100644 --- a/src/ast/variable.cc +++ b/src/ast/variable.cc @@ -125,7 +125,9 @@ void Variable::info_to_str(const semantic::Info& sem, out << (var_sem ? var_sem->StorageClass() : declared_storage_class()) << std::endl; make_indent(out, indent); - out << declared_type_->type_name() << std::endl; + if (declared_type_) { + out << declared_type_->type_name() << std::endl; + } } void Variable::constructor_to_str(const semantic::Info& sem,