Program: 103065
Project: 103065
Buggy source:
/** 
 * Updates a specific local <tt>MediaDescription</tt> and the state of this instance for the purposes of DTLS-SRTP.
 * @param mediaType the <tt>MediaType</tt> of the media described by<tt>localMd</tt> and <tt>remoteMd</tt>
 * @param localMd the local <tt>MediaDescription</tt> to be updated
 * @param remoteMd the remote <tt>MediaDescription</tt>, if any, associatedwith <tt>localMd</tt>
 * @return <tt>true</tt> if the specified <tt>localMd</tt> and/or the stateof this instance was updated for the purposes of DTLS-SRTP or <tt>false</tt> if the specified <tt>localMd</tt> (and <tt>remoteMd</tt>) did not concern DTLS-SRTP
 */
private boolean updateMediaDescriptionForDtls(MediaType mediaType,MediaDescription localMd,MediaDescription remoteMd){
  AccountID accountID=getPeer().getProtocolProvider().getAccountID();
  boolean b=false;
  if (accountID.getAccountPropertyBoolean(ProtocolProviderFactory.DEFAULT_ENCRYPTION,true) && accountID.isEncryptionProtocolEnabled(DtlsControl.PROTO_NAME)) {
    Media localMedia=localMd.getMedia();
    if (localMedia != null) {
      String proto;
      try {
        proto=localMedia.getProtocol();
      }
 catch (      SdpParseException e) {
        proto=null;
      }
      boolean dtls=DtlsControl.UDP_TLS_RTP_SAVP.equals(proto) || DtlsControl.UDP_TLS_RTP_SAVPF.equals(proto);
      SrtpControls srtpControls=getSrtpControls();
      if (dtls) {
        DtlsControl dtlsControl=(DtlsControl)srtpControls.getOrCreate(mediaType,SrtpControlType.DTLS_SRTP);
        @SuppressWarnings("String_Node_Str") Vector<Attribute> attrs=localMd.getAttributes(true);
        String setup=(remoteMd == null) ? DTLS_SRTP_SETUP_ACTPASS : DTLS_SRTP_SETUP_ACTIVE;
        Attribute setupAttr=SdpUtils.createAttribute(DTLS_SRTP_SETUP_ATTR,setup);
        attrs.add(setupAttr);
        String hashFunction=dtlsControl.getLocalFingerprintHashFunction();
        String fingerprint=dtlsControl.getLocalFingerprint();
        Attribute fingerprintAttr=SdpUtils.createAttribute(DTLS_SRTP_FINGERPRINT_ATTR,hashFunction + "String_Node_Str" + fingerprint);
        attrs.add(fingerprintAttr);
        int dtlsProtocol=DTLS_SRTP_SETUP_ACTIVE.equals(setup) ? DtlsControl.DTLS_CLIENT_PROTOCOL : DtlsControl.DTLS_SERVER_PROTOCOL;
        dtlsControl.setDtlsProtocol(dtlsProtocol);
        if (remoteMd != null)         updateSrtpControlsForDtls(mediaType,localMd,remoteMd);
        b=true;
      }
 else       if (remoteMd != null) {
        SrtpControl dtlsControl=srtpControls.remove(mediaType,SrtpControlType.DTLS_SRTP);
        if (dtlsControl != null)         dtlsControl.cleanup();
      }
    }
  }
  return b;
}

Fixed version (ground truth):
/** 
 * Updates a specific local <tt>MediaDescription</tt> and the state of this instance for the purposes of DTLS-SRTP.
 * @param mediaType the <tt>MediaType</tt> of the media described by<tt>localMd</tt> and <tt>remoteMd</tt>
 * @param localMd the local <tt>MediaDescription</tt> to be updated
 * @param remoteMd the remote <tt>MediaDescription</tt>, if any, associatedwith <tt>localMd</tt>
 * @return <tt>true</tt> if the specified <tt>localMd</tt> and/or the stateof this instance was updated for the purposes of DTLS-SRTP or <tt>false</tt> if the specified <tt>localMd</tt> (and <tt>remoteMd</tt>) did not concern DTLS-SRTP
 */
private boolean updateMediaDescriptionForDtls(MediaType mediaType,MediaDescription localMd,MediaDescription remoteMd){
  AccountID accountID=getPeer().getProtocolProvider().getAccountID();
  boolean b=false;
  if (accountID.getAccountPropertyBoolean(ProtocolProviderFactory.DEFAULT_ENCRYPTION,true) && accountID.isEncryptionProtocolEnabled(DtlsControl.PROTO_NAME)) {
    Media localMedia=localMd.getMedia();
    if (localMedia != null) {
      String proto;
      try {
        proto=localMedia.getProtocol();
      }
 catch (      SdpParseException e) {
        proto=null;
      }
      boolean dtls=DtlsControl.UDP_TLS_RTP_SAVP.equals(proto) || DtlsControl.UDP_TLS_RTP_SAVPF.equals(proto) || SrtpControl.RTP_SAVPF.equals(proto);
      if (dtls && (remoteMd != null))       dtls=isDtlsMediaDescription(remoteMd);
      SrtpControls srtpControls=getSrtpControls();
      if (dtls) {
        DtlsControl dtlsControl=(DtlsControl)srtpControls.getOrCreate(mediaType,SrtpControlType.DTLS_SRTP);
        @SuppressWarnings("String_Node_Str") Vector<Attribute> attrs=localMd.getAttributes(true);
        String setup=(remoteMd == null) ? DTLS_SRTP_SETUP_ACTPASS : DTLS_SRTP_SETUP_ACTIVE;
        Attribute setupAttr=SdpUtils.createAttribute(DTLS_SRTP_SETUP_ATTR,setup);
        attrs.add(setupAttr);
        String hashFunction=dtlsControl.getLocalFingerprintHashFunction();
        String fingerprint=dtlsControl.getLocalFingerprint();
        Attribute fingerprintAttr=SdpUtils.createAttribute(DTLS_SRTP_FINGERPRINT_ATTR,hashFunction + "String_Node_Str" + fingerprint);
        attrs.add(fingerprintAttr);
        int dtlsProtocol=DTLS_SRTP_SETUP_ACTIVE.equals(setup) ? DtlsControl.DTLS_CLIENT_PROTOCOL : DtlsControl.DTLS_SERVER_PROTOCOL;
        dtlsControl.setDtlsProtocol(dtlsProtocol);
        if (remoteMd != null)         updateSrtpControlsForDtls(mediaType,localMd,remoteMd);
        b=true;
      }
 else       if (remoteMd != null) {
        SrtpControl dtlsControl=srtpControls.remove(mediaType,SrtpControlType.DTLS_SRTP);
        if (dtlsControl != null)         dtlsControl.cleanup();
      }
    }
  }
  return b;
}