private int getStringPadLength(Program program, Address endAddress) {

		Address nextAddr = endAddress.next();
		if (nextAddr == null) {
			return 0;
		}

		long modResult = nextAddr.getOffset() % endAlignment;
		if (modResult == 0) {
			return 0;
		}

		int padBytesNeeded = endAlignment - (int) modResult;
		try {
			byte[] bytes = new byte[padBytesNeeded];
			if (program.getMemory().getBytes(nextAddr, bytes) == padBytesNeeded) {

				for (byte b : bytes) {
					if (b != 0) {
						return 0;
					}
				}
			}
		}
		catch (Exception e) {
			return 0;
		}

		return padBytesNeeded;
	}
Get number of zeros needed to pad the string to the specified alignment.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/string/StringsAnalyzer.java