summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2021-05-06 16:08:15 -0700
committerGitHub <noreply@github.com>2021-05-06 16:08:15 -0700
commita2725fd03febf32051811af2fa50fd0de3b61dde (patch)
treeb5f4c7c6af26d7bd23fc2cf49b56399f821d5512 /source
parent8ee5e4501c746e34a1b59c643422cca56e2be214 (diff)
Fix for uninitialized field (#1838)
The `OverloadedExpr` type didn't provide a default value for its field: Name* name; This led to a null-pointer crash in the logic that deals with synthesizing interface requirements because it creates an `OverloadedExpr` but doesn't initialize the field. This change makes two fixes: 1. The logic in the synthesis path actually initializes `name` so that it can feed into any downstream error messages 2. The `OverloadedExpr` declaration now includes an initial value for `name` so that it will at least be null instead of garbage if we slip up again
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ast-expr.h2
-rw-r--r--source/slang/slang-check-decl.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/source/slang/slang-ast-expr.h b/source/slang/slang-ast-expr.h
index a5024460b..d79982b5d 100644
--- a/source/slang/slang-ast-expr.h
+++ b/source/slang/slang-ast-expr.h
@@ -35,7 +35,7 @@ class OverloadedExpr : public Expr
SLANG_AST_CLASS(OverloadedExpr)
// The name that was looked up and found to be overloaded
- Name* name;
+ Name* name = nullptr;
// Optional: the base expression is this overloaded result
// arose from a member-reference expression.
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 726781fb0..0f6075903 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -2062,6 +2062,7 @@ namespace Slang
// expression.
//
auto synBase = m_astBuilder->create<OverloadedExpr>();
+ synBase->name = requiredMemberDeclRef.getDecl()->getName();
synBase->lookupResult2 = lookupResult;
// If `synThis` is non-null, then we will use it as the base of