#vulnerable code 
                              @Override
  public byte[] getBytes() {
    byte[] bytes = null;

    switch (addressType) {
      case AddressType.IPV4:
        bytes = new byte[10];
        byte[] ipv4Bytes = inetAddress.getAddress();// todo
        System.arraycopy(ipv4Bytes, 0, bytes, 4, ipv4Bytes.length);
        bytes[8] = SocksUtil.getFirstByteFromInt(port);
        bytes[9] = SocksUtil.getSecondByteFromInt(port);
        break;

      case AddressType.IPV6:
        bytes = new byte[22];
        byte[] ipv6Bytes = inetAddress.getAddress();// todo
        System.arraycopy(ipv6Bytes, 0, bytes, 4, ipv6Bytes.length);
        bytes[20] = SocksUtil.getFirstByteFromInt(port);
        bytes[21] = SocksUtil.getSecondByteFromInt(port);
        break;

      case AddressType.DOMAIN_NAME:
        final int hostLength = host.getBytes().length;
        bytes = new byte[7 + hostLength];
        bytes[4] = (byte) hostLength;
        for (int i = 0; i < hostLength; i++) {
          bytes[5 + i] = host.getBytes()[i];
        }
        bytes[5 + hostLength] = SocksUtil.getFirstByteFromInt(port);
        bytes[6 + hostLength] = SocksUtil.getSecondByteFromInt(port);
        break;
      default:
        break;
    }

    bytes[0] = (byte) version;
    bytes[1] = (byte) command.getValue();
    bytes[2] = RESERVED;
    bytes[3] = (byte) addressType;

    return bytes;
  } 
                            #location 36 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                              @Override
  public byte[] getBytes() {
    byte[] bytes = null;

    switch (addressType) {
      case AddressType.IPV4:
        bytes = new byte[10];
        byte[] ipv4Bytes = inetAddress.getAddress();// todo
        System.arraycopy(ipv4Bytes, 0, bytes, 4, ipv4Bytes.length);
        bytes[8] = SocksUtil.getFirstByteFromInt(port);
        bytes[9] = SocksUtil.getSecondByteFromInt(port);
        break;

      case AddressType.IPV6:
        bytes = new byte[22];
        byte[] ipv6Bytes = inetAddress.getAddress();// todo
        System.arraycopy(ipv6Bytes, 0, bytes, 4, ipv6Bytes.length);
        bytes[20] = SocksUtil.getFirstByteFromInt(port);
        bytes[21] = SocksUtil.getSecondByteFromInt(port);
        break;

      case AddressType.DOMAIN_NAME:
        final int hostLength = host.getBytes().length;
        bytes = new byte[7 + hostLength];
        bytes[4] = (byte) hostLength;
        for (int i = 0; i < hostLength; i++) {
          bytes[5 + i] = host.getBytes()[i];
        }
        bytes[5 + hostLength] = SocksUtil.getFirstByteFromInt(port);
        bytes[6 + hostLength] = SocksUtil.getSecondByteFromInt(port);
        break;
      default:
        break;
    }

    if (bytes != null) {
      bytes[0] = (byte) version;
      bytes[1] = (byte) command.getValue();
      bytes[2] = RESERVED;
      bytes[3] = (byte) addressType;
    }

    return bytes;
  }