Program: 72371
Project: 72371
Buggy source:
/** 
 * Convert the buffer to a message depending on the specified receive type and emit a 'message' event.
 * @param buffer The buffer containing the message.
 */
protected void _emitMessage(Buffer buffer){
  if (_receiveType == DATA_TYPE.STRING) {
    _currentObj.callMember("String_Node_Str","String_Node_Str",buffer.getString(0,buffer.length()));
  }
 else   if (_receiveType == DATA_TYPE.IMAGE) {
    try {
      byte[] bytes=buffer.getBytes();
      ByteArrayBackedInputStream byteStream=new ByteArrayBackedInputStream(bytes);
      BufferedImage image=ImageIO.read(byteStream);
      if (image != null && image.getHeight() > 0 && image.getWidth() > 0) {
        ImageToken token=new AWTImageToken(image);
        _currentObj.callMember("String_Node_Str","String_Node_Str",token);
      }
 else {
        _error(_currentObj,"String_Node_Str");
      }
    }
 catch (    IOException e) {
      _error(_currentObj,"String_Node_Str" + e.toString());
    }
  }
 else {
    int size=_sizeOfType(_receiveType);
    if (size == 0) {
      _error(_currentObj,"String_Node_Str" + _receiveType + "String_Node_Str");
    }
 else {
      int length=buffer.length();
      int numberOfElements=length / size;
      if (numberOfElements == 1) {
        _currentObj.callMember("String_Node_Str","String_Node_Str",_extractFromBuffer(buffer,_receiveType,0));
      }
 else       if (numberOfElements > 1) {
        Object[] result=new Object[numberOfElements];
        int position=0;
        for (int i=0; i < result.length; i++) {
          result[i]=_extractFromBuffer(buffer,_receiveType,position);
          position+=size;
        }
        try {
          _currentObj.callMember("String_Node_Str","String_Node_Str",_actor.toJSArray(result));
        }
 catch (        Exception e) {
          _error(_currentObj,"String_Node_Str" + e);
          _currentObj.callMember("String_Node_Str","String_Node_Str",result);
        }
      }
 else       if (numberOfElements <= 0) {
        _error(_currentObj,"String_Node_Str" + _receiveType + "String_Node_Str"+ buffer.length());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Convert the buffer to a message depending on the specified receive type and emit a 'message' event.
 * @param buffer The buffer containing the message.
 */
protected void _emitMessage(Buffer buffer){
  if (_receiveType == DATA_TYPE.STRING) {
    _currentObj.callMember("String_Node_Str","String_Node_Str",buffer.getString(0,buffer.length()));
  }
 else   if (_receiveType == DATA_TYPE.IMAGE) {
    try {
      byte[] bytes=buffer.getBytes();
      ByteArrayBackedInputStream byteStream=new ByteArrayBackedInputStream(bytes);
      BufferedImage image=ImageIO.read(byteStream);
      if (image != null && image.getHeight() > 0 && image.getWidth() > 0) {
        ImageToken token=new AWTImageToken(image);
        _currentObj.callMember("String_Node_Str","String_Node_Str",token);
      }
 else {
        _error(_currentObj,"String_Node_Str");
      }
    }
 catch (    IOException e) {
      _error(_currentObj,"String_Node_Str" + e.toString());
    }
  }
 else {
    int size=_sizeOfType(_receiveType);
    if (size == 0) {
      _error(_currentObj,"String_Node_Str" + _receiveType + "String_Node_Str");
    }
 else {
      int length=buffer.length();
      int numberOfElements=length / size;
      if (numberOfElements == 1) {
        _currentObj.callMember("String_Node_Str","String_Node_Str",_extractFromBuffer(buffer,_receiveType,0));
      }
 else       if (numberOfElements > 1) {
        Object[] result=new Object[numberOfElements];
        int position=0;
        for (int i=0; i < result.length; i++) {
          result[i]=_extractFromBuffer(buffer,_receiveType,position);
          position+=size;
        }
        try {
          _currentObj.callMember("String_Node_Str","String_Node_Str",_actor.toJSArray(result));
        }
 catch (        Exception e) {
          _error(_currentObj,"String_Node_Str" + e);
          _currentObj.callMember("String_Node_Str","String_Node_Str",result);
        }
      }
 else {
        _error(_currentObj,"String_Node_Str" + _receiveType + "String_Node_Str"+ buffer.length());
      }
    }
  }
}