From 2671c5d22d67071fed97e8d814466c38e7aa5148 Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Wed, 10 Jun 2020 17:17:06 -0400 Subject: [PATCH] Keep null records out of FID cache --- .../hash/FunctionBodyFunctionExtentGenerator.java | 15 ++++++++------- .../service/FIDFixedSizeMRUCachingFactory.java | 3 +++ .../feature/fid/service/FidHasherFactory.java | 3 --- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/hash/FunctionBodyFunctionExtentGenerator.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/hash/FunctionBodyFunctionExtentGenerator.java index 92b84b7fc5..99a92ca5b2 100644 --- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/hash/FunctionBodyFunctionExtentGenerator.java +++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/hash/FunctionBodyFunctionExtentGenerator.java @@ -19,12 +19,7 @@ import java.util.ArrayList; import java.util.List; import ghidra.program.model.address.AddressSetView; -import ghidra.program.model.listing.CodeUnit; -import ghidra.program.model.listing.Function; -import ghidra.program.model.listing.Instruction; -import ghidra.program.model.listing.InstructionIterator; -import ghidra.program.model.listing.Listing; -import ghidra.program.model.listing.Program; +import ghidra.program.model.listing.*; /** * Calculates the function extent by the function body; i.e. what's saved @@ -35,9 +30,15 @@ import ghidra.program.model.listing.Program; public class FunctionBodyFunctionExtentGenerator implements FunctionExtentGenerator { @Override public List calculateExtent(Function func) { + if (func == null) { + return List.of(); + } + final AddressSetView body = func.getBody(); + if (body.isEmpty()) { + return List.of(); + } ArrayList units = new ArrayList(); - final AddressSetView body = func.getBody(); final Program program = func.getProgram(); final Listing listing = program.getListing(); diff --git a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FIDFixedSizeMRUCachingFactory.java b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FIDFixedSizeMRUCachingFactory.java index 864d73a300..90f2fb36ee 100644 --- a/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FIDFixedSizeMRUCachingFactory.java +++ b/Ghidra/Features/FunctionID/src/main/java/ghidra/feature/fid/service/FIDFixedSizeMRUCachingFactory.java @@ -49,6 +49,9 @@ public class FIDFixedSizeMRUCachingFactory implements Factory { @Override public FidHashQuad get(Function function) { try { - if (function == null) { - return null; - } return hasher.hash(function); } catch (MemoryAccessException e) {