Skip to content
This repository has been archived by the owner on Jan 27, 2019. It is now read-only.

Commit

Permalink
Fix NRE for empty ProtectionParameters
Browse files Browse the repository at this point in the history
Fix #31
  • Loading branch information
yck1509 committed Jun 21, 2014
1 parent 3d416d5 commit 4be2740
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Confuser.Core/ProtectionParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ namespace Confuser.Core {
/// </summary>
public class ProtectionParameters {
private static readonly object ParametersKey = new object();
private readonly ConfuserComponent comp;

/// <summary>
/// A empty instance of <see cref="ProtectionParameters" />.
/// A empty instance of <see cref="ProtectionParameters" />.
/// </summary>
public static readonly ProtectionParameters Empty = new ProtectionParameters(null, new IDnlibDef[0]);

private readonly ConfuserComponent comp;

/// <summary>
/// Initializes a new instance of the <see cref="ProtectionParameters" /> class.
/// </summary>
Expand Down Expand Up @@ -47,11 +48,13 @@ internal ProtectionParameters(ConfuserComponent component, IList<IDnlibDef> targ
public T GetParameter<T>(ConfuserContext context, IDnlibDef target, string name, T defValue = default(T)) {
Dictionary<string, string> parameters;

if (comp == null)
return defValue;

// For packers
if (comp is Packer) {
parameters = new Dictionary<string, string>(context.Project.Packer, StringComparer.OrdinalIgnoreCase);
}
else {
} else {
// For protections
var objParams = context.Annotations.Get<ProtectionSettings>(target, ParametersKey);
if (objParams == null)
Expand Down

0 comments on commit 4be2740

Please sign in to comment.