From 049b5903d844a013d66616bdb2cf6def8a2a0c7c Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 20 Sep 2017 09:24:14 +0200 Subject: [PATCH] Fix #862 - NullReferenceException for ExpressionBuilder.TranslateTarget --- ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs index caef241c1..f2cb414e1 100644 --- a/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs @@ -1083,7 +1083,9 @@ namespace ICSharpCode.Decompiler.CSharp TranslatedExpression TranslateTarget(IMember member, ILInstruction target, bool nonVirtualInvocation) { - if (!member.IsStatic) { + // If references are missing member.IsStatic might not be set correctly. + // Additionally check target for null, in order to avoid a crash. + if (!member.IsStatic && target != null) { if (nonVirtualInvocation && target.MatchLdThis() && member.DeclaringTypeDefinition != resolver.CurrentTypeDefinition) { return new BaseReferenceExpression() .WithILInstruction(target)