GP-3452: PointerType.RELATIVE now treats 0 as NaP

This commit is contained in:
Ryan Kurtz 2023-05-22 06:59:26 -04:00
parent ce8fadf7a8
commit d3ab0197c2

View file

@ -445,7 +445,7 @@ public class PointerDataType extends BuiltIn implements Pointer {
if (pointerType == PointerType.IMAGE_BASE_RELATIVE) { if (pointerType == PointerType.IMAGE_BASE_RELATIVE) {
if (addrOffset == 0) { if (addrOffset == 0) {
// Done for consistency with old ImageBaseOffsetDataType. // Done for consistency with old ImageBaseOffsetDataType.
// A 0 relative offset is considerd invalid (NaP) // A 0 relative offset is considered invalid (NaP)
return null; // NaP without error return null; // NaP without error
} }
if (mem == null) { if (mem == null) {
@ -457,6 +457,10 @@ public class PointerDataType extends BuiltIn implements Pointer {
return imageBase.addWrap(addrOffset * targetSpace.getAddressableUnitSize()); return imageBase.addWrap(addrOffset * targetSpace.getAddressableUnitSize());
} }
else if (pointerType == PointerType.RELATIVE) { else if (pointerType == PointerType.RELATIVE) {
if (addrOffset == 0) {
// A 0 relative offset is considered invalid (NaP)
return null; // NaP without error
}
// must ignore AddressSpaceSettingsDefinition // must ignore AddressSpaceSettingsDefinition
Address base = buf.getAddress(); Address base = buf.getAddress();
targetSpace = base.getAddressSpace(); targetSpace = base.getAddressSpace();