Program: 53265
Project: 53265
Buggy source:
/** 
 * Reserved for internal use.
 */
final byte[][] generateMessage(Object name,byte[] data,ObjectType interfaceClass,int AttributeOrdinal,Command cmd){
  if (getLimits().getMaxInfoRX() == null) {
    throw new GXDLMSException("String_Node_Str");
  }
  java.nio.ByteBuffer buff;
  if (name instanceof byte[]) {
    buff=java.nio.ByteBuffer.wrap((byte[])name);
  }
 else {
    if (name == null) {
      buff=java.nio.ByteBuffer.wrap(data);
    }
 else     if (getUseLogicalNameReferencing()) {
      int len=data == null ? 0 : data.length;
      buff=java.nio.ByteBuffer.allocate(20 + len);
      if (cmd == Command.GetRequest || cmd == Command.SetRequest || cmd == Command.MethodRequest) {
        buff.putShort((short)interfaceClass.getValue());
        String[] items=((String)name).split("String_Node_Str",-1);
        if (items.length != 6) {
          throw new GXDLMSException("String_Node_Str");
        }
        for (        String it : items) {
          buff.put((byte)(Short.parseShort(it) & 0xFF));
        }
        buff.put((byte)AttributeOrdinal);
        if (data == null || data.length == 0 || cmd == Command.SetRequest) {
          buff.put((byte)0);
        }
 else {
          buff.put((byte)1);
        }
      }
    }
 else {
      int len=data == null ? 0 : data.length;
      buff=java.nio.ByteBuffer.allocate(11 + len);
      if (name.getClass().isArray()) {
        for (int pos=0; pos != Array.getLength(name); ++pos) {
          Object it=Array.get(name,pos);
          buff.put((byte)2);
          int base_address=((Number)it).shortValue() & 0xFFFF;
          base_address+=((AttributeOrdinal - 1) * 8);
          buff.putShort((short)base_address);
        }
      }
 else {
        buff.put((byte)1);
      }
      if (cmd == Command.ReadResponse || cmd == Command.WriteResponse) {
        buff.put((byte)0x0);
      }
 else {
        if (data == null || data.length == 0) {
          buff.put((byte)2);
        }
 else {
          buff.put((byte)4);
        }
        int base_address=GXCommon.intValue(name);
        if (AttributeOrdinal != 0) {
          base_address+=((AttributeOrdinal - 1) * 8);
        }
        buff.putShort((short)base_address);
      }
    }
    if (data != null && data.length != 0) {
      buff.put(data);
    }
  }
  return splitToBlocks(buff,cmd);
}

Fixed version (ground truth):
/** 
 * Reserved for internal use.
 */
final byte[][] generateMessage(Object name,byte[] data,ObjectType interfaceClass,int AttributeOrdinal,Command cmd){
  if (getLimits().getMaxInfoRX() == null) {
    throw new GXDLMSException("String_Node_Str");
  }
  boolean asList=false;
  java.nio.ByteBuffer buff;
  if (name instanceof byte[]) {
    buff=java.nio.ByteBuffer.wrap((byte[])name);
  }
 else {
    if (name == null) {
      buff=java.nio.ByteBuffer.wrap(data);
    }
 else     if (getUseLogicalNameReferencing()) {
      int len=data == null ? 0 : data.length;
      if (cmd == Command.GetRequest || cmd == Command.SetRequest || cmd == Command.MethodRequest) {
        if (name instanceof List) {
          asList=true;
          List<AbstractMap.SimpleEntry<GXDLMSObject,Integer>> tmp=(List<AbstractMap.SimpleEntry<GXDLMSObject,Integer>>)name;
          buff=java.nio.ByteBuffer.allocate(20 + len + tmp.size() * 10);
          buff.put((byte)tmp.size());
          for (          AbstractMap.SimpleEntry<GXDLMSObject,Integer> it : tmp) {
            GXCommon.setUInt16((short)it.getKey().getObjectType().getValue(),buff);
            String[] items=it.getKey().getLogicalName().split("String_Node_Str");
            if (items.length != 6) {
              throw new GXDLMSException("String_Node_Str");
            }
            for (            String it2 : items) {
              buff.put(Integer.valueOf(it2).byteValue());
            }
            buff.put(it.getValue().byteValue());
            buff.put((byte)0);
          }
        }
 else {
          buff=java.nio.ByteBuffer.allocate(20 + len);
          buff.putShort((short)interfaceClass.getValue());
          String[] items=((String)name).split("String_Node_Str",-1);
          if (items.length != 6) {
            throw new GXDLMSException("String_Node_Str");
          }
          for (          String it : items) {
            buff.put((byte)(Short.parseShort(it) & 0xFF));
          }
          buff.put((byte)AttributeOrdinal);
          if (data == null || data.length == 0 || cmd == Command.SetRequest) {
            buff.put((byte)0);
          }
 else {
            buff.put((byte)1);
          }
        }
      }
 else {
        buff=java.nio.ByteBuffer.allocate(20 + len);
      }
    }
 else {
      int len=data == null ? 0 : data.length;
      if (name instanceof List) {
        List<AbstractMap.SimpleEntry<GXDLMSObject,Integer>> tmp=(List<AbstractMap.SimpleEntry<GXDLMSObject,Integer>>)name;
        buff=java.nio.ByteBuffer.allocate(10 + tmp.size() * 3);
        buff.put((byte)tmp.size());
        for (        AbstractMap.SimpleEntry<GXDLMSObject,Integer> it : tmp) {
          buff.put((byte)2);
          int base_address=it.getKey().getShortName();
          base_address+=((it.getValue() - 1) * 8);
          GXCommon.setUInt16((short)base_address,buff);
        }
      }
 else {
        buff=java.nio.ByteBuffer.allocate(11 + len);
        buff.put((byte)1);
        if (cmd == Command.ReadResponse || cmd == Command.WriteResponse) {
          buff.put((byte)0x0);
        }
 else {
          if (data == null || data.length == 0) {
            buff.put((byte)2);
          }
 else {
            buff.put((byte)4);
          }
          int base_address=GXCommon.intValue(name);
          if (AttributeOrdinal != 0) {
            base_address+=((AttributeOrdinal - 1) * 8);
          }
          buff.putShort((short)base_address);
        }
      }
    }
    if (data != null && data.length != 0) {
      buff.put(data);
    }
  }
  return splitToBlocks(buff,cmd,asList);
}