Don't add to list if null

This commit is contained in:
de4dot 2012-04-05 17:06:27 +02:00
parent 9cfe8431f6
commit 1ead27107b

View File

@ -340,6 +340,7 @@ namespace de4dot.code.deobfuscators {
} }
protected void addMethodToBeRemoved(MethodDefinition method, string reason) { protected void addMethodToBeRemoved(MethodDefinition method, string reason) {
if (method != null)
methodsToRemove.Add(new RemoveInfo<MethodDefinition>(method, reason)); methodsToRemove.Add(new RemoveInfo<MethodDefinition>(method, reason));
} }
@ -349,10 +350,13 @@ namespace de4dot.code.deobfuscators {
} }
protected void addFieldToBeRemoved(FieldDefinition field, string reason) { protected void addFieldToBeRemoved(FieldDefinition field, string reason) {
if (field != null)
fieldsToRemove.Add(new RemoveInfo<FieldDefinition>(field, reason)); fieldsToRemove.Add(new RemoveInfo<FieldDefinition>(field, reason));
} }
protected void addAttributeToBeRemoved(TypeDefinition attr, string reason) { protected void addAttributeToBeRemoved(TypeDefinition attr, string reason) {
if (attr == null)
return;
addTypeToBeRemoved(attr, reason); addTypeToBeRemoved(attr, reason);
attrsToRemove.Add(new RemoveInfo<TypeDefinition>(attr, reason)); attrsToRemove.Add(new RemoveInfo<TypeDefinition>(attr, reason));
} }
@ -363,10 +367,12 @@ namespace de4dot.code.deobfuscators {
} }
protected void addTypeToBeRemoved(TypeDefinition type, string reason) { protected void addTypeToBeRemoved(TypeDefinition type, string reason) {
if (type != null)
typesToRemove.Add(new RemoveInfo<TypeDefinition>(type, reason)); typesToRemove.Add(new RemoveInfo<TypeDefinition>(type, reason));
} }
protected void addResourceToBeRemoved(Resource resource, string reason) { protected void addResourceToBeRemoved(Resource resource, string reason) {
if (resource != null)
resourcesToRemove.Add(new RemoveInfo<Resource>(resource, reason)); resourcesToRemove.Add(new RemoveInfo<Resource>(resource, reason));
} }
@ -376,10 +382,12 @@ namespace de4dot.code.deobfuscators {
} }
protected void addModuleReferenceToBeRemoved(ModuleReference modref, string reason) { protected void addModuleReferenceToBeRemoved(ModuleReference modref, string reason) {
if (modref != null)
modrefsToRemove.Add(new RemoveInfo<ModuleReference>(modref, reason)); modrefsToRemove.Add(new RemoveInfo<ModuleReference>(modref, reason));
} }
protected void addAssemblyReferenceToBeRemoved(AssemblyNameReference asmRef, string reason) { protected void addAssemblyReferenceToBeRemoved(AssemblyNameReference asmRef, string reason) {
if (asmRef != null)
asmrefsToRemove.Add(new RemoveInfo<AssemblyNameReference>(asmRef, reason)); asmrefsToRemove.Add(new RemoveInfo<AssemblyNameReference>(asmRef, reason));
} }