Skip to content

Commit a2725fd

Browse files
author
Tim Foley
authored
Fix for uninitialized field (shader-slang#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
1 parent 8ee5e45 commit a2725fd

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

source/slang/slang-ast-expr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class OverloadedExpr : public Expr
3535
SLANG_AST_CLASS(OverloadedExpr)
3636

3737
// The name that was looked up and found to be overloaded
38-
Name* name;
38+
Name* name = nullptr;
3939

4040
// Optional: the base expression is this overloaded result
4141
// arose from a member-reference expression.

source/slang/slang-check-decl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,7 @@ namespace Slang
20622062
// expression.
20632063
//
20642064
auto synBase = m_astBuilder->create<OverloadedExpr>();
2065+
synBase->name = requiredMemberDeclRef.getDecl()->getName();
20652066
synBase->lookupResult2 = lookupResult;
20662067

20672068
// If `synThis` is non-null, then we will use it as the base of

0 commit comments

Comments
 (0)