Program: 87782
Project: 87782
Buggy source:
private void processEnvelopeWithBuffer(final TransferEnvelope transferEnvelope,final TransferEnvelopeReceiverList receiverList,final boolean freeSourceBuffer){
  if (!freeSourceBuffer) {
    final List<ChannelID> localReceivers=receiverList.getLocalReceivers();
    if (localReceivers.size() != 1) {
      LOG.error("String_Node_Str");
    }
    final ChannelID localReceiver=localReceivers.get(0);
    final ChannelContext cc=this.registeredChannels.get(localReceiver);
    if (cc == null) {
      sendReceiverNotFoundEvent(transferEnvelope,localReceiver);
      recycleBuffer(transferEnvelope);
      return;
    }
    if (!cc.isInputChannel()) {
      LOG.error("String_Node_Str" + localReceiver + "String_Node_Str");
    }
    cc.queueTransferEnvelope(transferEnvelope);
    return;
  }
  final Buffer srcBuffer=transferEnvelope.getBuffer();
  if (receiverList.hasLocalReceivers()) {
    final List<ChannelID> localReceivers=receiverList.getLocalReceivers();
    for (    final ChannelID localReceiver : localReceivers) {
      final ChannelContext cc=this.registeredChannels.get(localReceiver);
      if (cc == null) {
        sendReceiverNotFoundEvent(transferEnvelope,localReceiver);
        continue;
      }
      if (!cc.isInputChannel()) {
        LOG.error("String_Node_Str" + localReceiver + "String_Node_Str");
        continue;
      }
      final InputChannelContext inputChannelContext=(InputChannelContext)cc;
      Buffer destBuffer=null;
      try {
        destBuffer=inputChannelContext.requestEmptyBufferBlocking(srcBuffer.size());
        srcBuffer.copyToBuffer(destBuffer);
      }
 catch (      Exception e) {
        LOG.error(StringUtils.stringifyException(e));
        if (destBuffer != null) {
          destBuffer.recycleBuffer();
        }
        continue;
      }
      final TransferEnvelope dup=transferEnvelope.duplicateWithoutBuffer();
      dup.setBuffer(destBuffer);
      inputChannelContext.queueTransferEnvelope(dup);
    }
  }
  if (receiverList.hasRemoteReceivers()) {
    final List<InetSocketAddress> remoteReceivers=receiverList.getRemoteReceivers();
    for (    final InetSocketAddress remoteReceiver : remoteReceivers) {
      TransferEnvelope dup=null;
      try {
        dup=transferEnvelope.duplicate();
      }
 catch (      Exception e) {
        LOG.error(StringUtils.stringifyException(e));
        if (dup != null) {
          recycleBuffer(dup);
          continue;
        }
      }
      this.networkConnectionManager.queueEnvelopeForTransfer(remoteReceiver,dup);
    }
  }
  srcBuffer.recycleBuffer();
}

Fixed version (ground truth):
private void processEnvelopeWithBuffer(final TransferEnvelope transferEnvelope,final TransferEnvelopeReceiverList receiverList,final boolean freeSourceBuffer){
  if (!freeSourceBuffer) {
    final List<ChannelID> localReceivers=receiverList.getLocalReceivers();
    if (localReceivers.size() != 1) {
      LOG.error("String_Node_Str");
    }
    final ChannelID localReceiver=localReceivers.get(0);
    final ChannelContext cc=this.registeredChannels.get(localReceiver);
    if (cc == null) {
      sendReceiverNotFoundEvent(transferEnvelope,localReceiver);
      recycleBuffer(transferEnvelope);
      return;
    }
    if (!cc.isInputChannel()) {
      LOG.error("String_Node_Str" + localReceiver + "String_Node_Str");
    }
    cc.queueTransferEnvelope(transferEnvelope);
    return;
  }
  final Buffer srcBuffer=transferEnvelope.getBuffer();
  if (receiverList.hasLocalReceivers()) {
    final List<ChannelID> localReceivers=receiverList.getLocalReceivers();
    for (    final ChannelID localReceiver : localReceivers) {
      final ChannelContext cc=this.registeredChannels.get(localReceiver);
      if (cc == null) {
        sendReceiverNotFoundEvent(transferEnvelope,localReceiver);
        continue;
      }
      if (!cc.isInputChannel()) {
        LOG.error("String_Node_Str" + localReceiver + "String_Node_Str");
        continue;
      }
      final InputChannelContext inputChannelContext=(InputChannelContext)cc;
      if (srcBuffer.isBackedByMemory()) {
        Buffer destBuffer=null;
        try {
          destBuffer=inputChannelContext.requestEmptyBufferBlocking(srcBuffer.size());
          srcBuffer.copyToBuffer(destBuffer);
        }
 catch (        Exception e) {
          LOG.error(StringUtils.stringifyException(e));
          if (destBuffer != null) {
            destBuffer.recycleBuffer();
          }
          continue;
        }
        final TransferEnvelope dup=transferEnvelope.duplicateWithoutBuffer();
        dup.setBuffer(destBuffer);
        inputChannelContext.queueTransferEnvelope(dup);
      }
 else {
        TransferEnvelope dup=null;
        try {
          dup=transferEnvelope.duplicate();
        }
 catch (        Exception e) {
          LOG.error(StringUtils.stringifyException(e));
          continue;
        }
        inputChannelContext.queueTransferEnvelope(dup);
      }
    }
  }
  if (receiverList.hasRemoteReceivers()) {
    final List<InetSocketAddress> remoteReceivers=receiverList.getRemoteReceivers();
    for (    final InetSocketAddress remoteReceiver : remoteReceivers) {
      TransferEnvelope dup=null;
      try {
        dup=transferEnvelope.duplicate();
      }
 catch (      Exception e) {
        LOG.error(StringUtils.stringifyException(e));
        if (dup != null) {
          recycleBuffer(dup);
          continue;
        }
      }
      this.networkConnectionManager.queueEnvelopeForTransfer(remoteReceiver,dup);
    }
  }
  srcBuffer.recycleBuffer();
}