Address checkMemoryAddress(Component c, Program p, Address addr, long refOffset) {
		String warningMsg = "";
		String refOffStr = "";
		if (refOffset != 0) {
			boolean neg = (refOffset < 0);
			refOffStr = (neg ? "-" : "+") + "0x" + Long.toHexString(neg ? -refOffset : refOffset);
		}
		AddressSpace space = addr.getAddressSpace();
		if (space instanceof OverlayAddressSpace) {
			OverlayAddressSpace overlaySpace = (OverlayAddressSpace) space;
			AddressSpace baseSpace =
				p.getAddressFactory().getAddressSpace(overlaySpace.getBaseSpaceID());
			long offset = baseSpace.truncateOffset(addr.getOffset() + refOffset);
			if (!overlaySpace.contains(offset)) {
				Address newAddr = overlaySpace.translateAddress(addr, true);
				warningMsg += "The overlay address " + addr.toString(true) + refOffStr +
					" is not contained within the overlay space '" + overlaySpace.getName() +
					"'\n" + "and will get mapped into the underlying address space (" +
					newAddr.toString(true) + refOffStr + ").\n \n";
				addr = newAddr;
			}
		}
		Address testAddr = addr;
		String wrapStr = "";
		if (refOffset != 0) {
			try {
				testAddr = addr.addNoWrap(refOffset);
			}
			catch (AddressOverflowException e) {
				warningMsg += "The address " + addr.toString(true) + refOffStr +
					" must be wrapped within the address space.\n \n";
				testAddr = addr.addWrap(refOffset);
				wrapStr = "wrapped ";
			}
		}
		if (!p.getMemory().contains(testAddr)) {
			warningMsg += "The equivalent " + wrapStr + "address " + testAddr.toString(true) +
				" is not contained within the Program's defined memory blocks.\n \n";
		}
		if (warningMsg.length() != 0) {
			if (c == null) {
				c = tool.getToolFrame();
			}
			int rc = OptionDialog.showOptionDialog(c, "Set Memory Reference",
				warningMsg + "Do you wish to continue?", "Continue", OptionDialog.WARNING_MESSAGE);
			if (rc != OptionDialog.OPTION_ONE) {
				return null;
			}
		}
		return addr;
	}
Check a memory address and warn the user if it has an issue.

@param c parent component or null
@param mem program memory
@param addr address to check
@param refOffset offset from addr
@return addr to be used or null if user cancels
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/references/ReferencesPlugin.java