From 4be274072363e42f26a6aab817c76901836f38e6 Mon Sep 17 00:00:00 2001 From: yck1509 Date: Sat, 21 Jun 2014 15:32:08 +0800 Subject: [PATCH] Fix NRE for empty ProtectionParameters Fix #31 --- Confuser.Core/ProtectionParameters.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Confuser.Core/ProtectionParameters.cs b/Confuser.Core/ProtectionParameters.cs index f7b8d1d68..632a0cb49 100644 --- a/Confuser.Core/ProtectionParameters.cs +++ b/Confuser.Core/ProtectionParameters.cs @@ -10,13 +10,14 @@ namespace Confuser.Core { /// public class ProtectionParameters { private static readonly object ParametersKey = new object(); - private readonly ConfuserComponent comp; /// - /// A empty instance of . + /// A empty instance of . /// public static readonly ProtectionParameters Empty = new ProtectionParameters(null, new IDnlibDef[0]); + private readonly ConfuserComponent comp; + /// /// Initializes a new instance of the class. /// @@ -47,11 +48,13 @@ internal ProtectionParameters(ConfuserComponent component, IList targ public T GetParameter(ConfuserContext context, IDnlibDef target, string name, T defValue = default(T)) { Dictionary parameters; + if (comp == null) + return defValue; + // For packers if (comp is Packer) { parameters = new Dictionary(context.Project.Packer, StringComparer.OrdinalIgnoreCase); - } - else { + } else { // For protections var objParams = context.Annotations.Get(target, ParametersKey); if (objParams == null)