public static Address getAddressValue(MemBuffer buf, int size, AddressSpace targetSpace) {

		if (size <= 0 || size > 8) {
			return null;
		}

		Long offset = getStoredOffset(buf, size, false, null);
		if (offset == null) {
			return null; // Insufficient bytes
		}

		if (targetSpace instanceof SegmentedAddressSpace) {
			try {
				// NOTE: conversion assumes a little-endian space
				return getSegmentedAddressValue(buf, size, offset);
			}
			catch (AddressOutOfBoundsException e) {
				// offset too large
			}
			catch (IllegalArgumentException iae) {
				// Do nothing... Tried to create an address that was too large
				// for the address space
				//
				// For example, trying to create a 56 bit pointer in a
				// 32 bit address space.
			}
			return null;
		}

		try {
			return targetSpace.getAddress(offset, true);
		}
		catch (AddressOutOfBoundsException e) {
			// offset too large
		}
		return null;
	}
Generate an address value based upon bytes stored at the specified buf
location.  The stored bytes will be interpreted as an unsigned byte 
offset into the specified targetSpace.

@param buf         memory buffer and stored pointer location
@param size        pointer size in bytes
@param targetSpace address space for returned address
@return address value or null if unusable buf or data
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/PointerDataType.java