Skip to content

Commit b41a32f

Browse files
committed
Merge pull request #781 from mjbvz/AnalyzeWorker-null-checks
Add two more null checks to AnalyzeWorker
2 parents 342e894 + 6f667f1 commit b41a32f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Nodejs/Product/Analysis/Analysis/Analyzer/AnalysisUnit.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ internal void Analyze(DDG ddg, CancellationToken cancel) {
193193
internal virtual void AnalyzeWorker(DDG ddg, CancellationToken cancel) {
194194
Debug.Assert(Ast != null, "Ast has unexpected null value");
195195
Debug.Assert(ProjectEntry != null, "ProjectEntry has unexpected null value");
196+
Debug.Assert(DeclaringModuleEnvironment != null, "DeclaringModuleEnvironment has unexpected null value");
197+
Debug.Assert(DeclaringModuleEnvironment.GlobalEnvironment != null, "DeclaringModuleEnvironment.GlobalEnvironment has unexpected null value");
196198

197-
if (Ast == null || ProjectEntry == null || Tree != ProjectEntry.Tree) {
199+
if (Ast == null || ProjectEntry == null || Tree != ProjectEntry.Tree || DeclaringModuleEnvironment == null) {
198200
// analysis unit properties are invalid or we were enqueued and a new version became available
199201
// don't re-analyze against the old version.
200202
return;
@@ -216,7 +218,10 @@ internal virtual void AnalyzeWorker(DDG ddg, CancellationToken cancel) {
216218
}
217219

218220
foreach (var nameValue in toRemove) {
219-
DeclaringModuleEnvironment.GlobalEnvironment.RemoveVariable(nameValue.Key);
221+
var globalEnvironment = DeclaringModuleEnvironment.GlobalEnvironment;
222+
if (globalEnvironment != null) {
223+
globalEnvironment.RemoveVariable(nameValue.Key);
224+
}
220225

221226
// if anyone read this value it could now be gone (e.g. user
222227
// deletes a class definition) so anyone dependent upon it

0 commit comments

Comments
 (0)