Skip to content

Ghidra is a software reverse engineering (SRE) framework

review fixes

ghidravore265e01027396
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryBlockSourceInfo.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryBlockSourceInfo.java
index 6c63536d56..6f145312d4 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryBlockSourceInfo.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/database/mem/MemoryBlockSourceInfo.java
@@ -99,17 +99,14 @@ public class MemoryBlockSourceInfo {
/**
* Returns the offset into the {@link FileBytes} object for the given address or
- * -1 if this SourceInfo does not have an associated {@link FileBytes} or the address doesn't
- * belong to this SourceInfo.
+ * -1 if this MemoryBlockSourceInfo does not have an associated {@link FileBytes} or the address doesn't
+ * belong to this MemoryBlockSourceInfo.
*
* @param address the address for which to get an offset into the {@link FileBytes} object.
* @return the offset into the {@link FileBytes} object for the given address.
*/
public long getFileBytesOffset(Address address) {
- if (!contains(address)) {
- return -1;
- }
- if (subBlock instanceof FileBytesSubMemoryBlock) {
+ if (subBlock instanceof FileBytesSubMemoryBlock && contains(address)) {
long blockOffset = address.subtract(getMinAddress());
long subBlockOffset = blockOffset - subBlock.startingOffset;
return ((FileBytesSubMemoryBlock) subBlock).getFileBytesOffset() + subBlockOffset;
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java
index 35b24ef806..98ecef9df7 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/mem/Memory.java
@@ -752,8 +752,9 @@ public interface Memory extends AddressSetView {
/**
* Returns information ({@link AddressSourceInfo}) about the byte source at the given address.
- * @param address the address to query.
- * @return information ({@link AddressSourceInfo}) about the byte source at the given address.
+ * @param address the address to query. Returns null if the address is not in memory.
+ * @return information ({@link AddressSourceInfo}) about the byte source at the given address or
+ * null if the address is not in memory.
*/
public AddressSourceInfo getAddressSourceInfo(Address address);
}