Program: 104256
Project: 104256
Buggy source:
/** 
 * Creates a vector containing SDP descriptions of media types and formats that we support. If the offerVector is non null
 * @param offerMediaDescs the media descriptions sent by the offerer (couldbe null).
 * @param publicAudioAddress the <tt>InetSocketAddress</tt> that we shouldbe using for sending audio.
 * @param publicVideoAddress the <tt>InetSocketAddress</tt> that we shouldbe using for sending video.
 * @return a <tt>Vector</tt> containing media descriptions that we supportand (if this is an answer to an offer) that the offering <tt>CallParticipant</tt> supports as well.
 * @throws SdpException we fail creating the media descriptions
 * @throws MediaException with code UNSUPPORTED_FORMAT_SET_ERROR if we don'tsupport any of the offered media formats.
 */
private Vector createMediaDescriptions(Vector<MediaDescription> offerMediaDescs,InetSocketAddress publicAudioAddress,InetSocketAddress publicVideoAddress) throws SdpException, MediaException {
  MediaControl mediaControl=mediaServCallback.getMediaControl(getCall());
  String[] supportedAudioEncodings=mediaControl.getSupportedAudioEncodings();
  String[] supportedVideoEncodings=mediaControl.getSupportedVideoEncodings();
  if (offerMediaDescs != null && offerMediaDescs.size() > 0) {
    Vector<String> offeredVideoEncodings=new Vector<String>();
    Vector<String> offeredAudioEncodings=new Vector<String>();
    Iterator<MediaDescription> offerDescsIter=offerMediaDescs.iterator();
    while (offerDescsIter.hasNext()) {
      MediaDescription desc=offerDescsIter.next();
      Media media=desc.getMedia();
      String mediaType=media.getMediaType();
      if (mediaType.equalsIgnoreCase("String_Node_Str")) {
        offeredVideoEncodings=media.getMediaFormats(true);
        continue;
      }
      if (mediaType.equalsIgnoreCase("String_Node_Str")) {
        offeredAudioEncodings=media.getMediaFormats(true);
        continue;
      }
    }
    Hashtable<String,List<String>> encodings=new Hashtable<String,List<String>>(2);
    encodings.put("String_Node_Str",offeredAudioEncodings);
    encodings.put("String_Node_Str",offeredVideoEncodings);
    encodings=intersectMediaEncodings(encodings);
    List<String> intersectedAudioEncsList=(List<String>)encodings.get("String_Node_Str");
    List<String> intersectedVideoEncsList=(List<String>)encodings.get("String_Node_Str");
    supportedAudioEncodings=intersectedAudioEncsList.toArray(new String[0]);
    supportedVideoEncodings=intersectedVideoEncsList.toArray(new String[0]);
  }
  Vector mediaDescs=new Vector();
  if (supportedAudioEncodings.length > 0) {
    MediaDescription am=mediaServCallback.getSdpFactory().createMediaDescription("String_Node_Str",publicAudioAddress.getPort(),1,"String_Node_Str",supportedAudioEncodings);
    String g723Str=String.valueOf(SdpConstants.G723);
    for (int i=0; i < supportedAudioEncodings.length; i++) {
      if (supportedAudioEncodings[i].equals(g723Str)) {
        am.setAttribute("String_Node_Str","String_Node_Str");
        am.setAttribute("String_Node_Str","String_Node_Str");
      }
    }
    byte onHold=this.onHold;
    if (!mediaServCallback.getDeviceConfiguration().isAudioCaptureSupported()) {
      onHold|=ON_HOLD_REMOTELY;
    }
    setAttributeOnHold(am,onHold);
    mediaDescs.add(am);
  }
  if (supportedVideoEncodings.length > 0) {
    MediaDescription vm=mediaServCallback.getSdpFactory().createMediaDescription("String_Node_Str",publicVideoAddress.getPort(),1,"String_Node_Str",supportedVideoEncodings);
    String h264Str=String.valueOf(Constants.H264_RTP_SDP);
    for (int i=0; i < supportedVideoEncodings.length; i++) {
      if (supportedVideoEncodings[i].equals(h264Str)) {
        vm.setAttribute("String_Node_Str",Constants.H264_RTP_SDP + "String_Node_Str");
        vm.setAttribute("String_Node_Str",Constants.H264_RTP_SDP + "String_Node_Str");
      }
    }
    byte onHold=this.onHold;
    if (!mediaServCallback.getDeviceConfiguration().isVideoCaptureSupported()) {
      onHold|=ON_HOLD_REMOTELY;
    }
    setAttributeOnHold(vm,onHold);
    mediaDescs.add(vm);
  }
  return mediaDescs;
}

Fixed version (ground truth):
/** 
 * Creates a vector containing SDP descriptions of media types and formats that we support. If the offerVector is non null
 * @param offerMediaDescs the media descriptions sent by the offerer (couldbe null).
 * @param publicAudioAddress the <tt>InetSocketAddress</tt> that we shouldbe using for sending audio.
 * @param publicVideoAddress the <tt>InetSocketAddress</tt> that we shouldbe using for sending video.
 * @return a <tt>Vector</tt> containing media descriptions that we supportand (if this is an answer to an offer) that the offering <tt>CallParticipant</tt> supports as well.
 * @throws SdpException we fail creating the media descriptions
 * @throws MediaException with code UNSUPPORTED_FORMAT_SET_ERROR if we don'tsupport any of the offered media formats.
 */
private Vector<MediaDescription> createMediaDescriptions(Vector<MediaDescription> offerMediaDescs,InetSocketAddress publicAudioAddress,InetSocketAddress publicVideoAddress) throws SdpException, MediaException {
  MediaControl mediaControl=mediaServCallback.getMediaControl(getCall());
  String[] supportedAudioEncodings=mediaControl.getSupportedAudioEncodings();
  String[] supportedVideoEncodings=mediaControl.getSupportedVideoEncodings();
  if (offerMediaDescs != null && offerMediaDescs.size() > 0) {
    Vector<String> offeredVideoEncodings=new Vector<String>();
    Vector<String> offeredAudioEncodings=new Vector<String>();
    Iterator<MediaDescription> offerDescsIter=offerMediaDescs.iterator();
    while (offerDescsIter.hasNext()) {
      MediaDescription desc=offerDescsIter.next();
      Media media=desc.getMedia();
      String mediaType=media.getMediaType();
      if (mediaType.equalsIgnoreCase("String_Node_Str")) {
        offeredVideoEncodings=media.getMediaFormats(true);
        continue;
      }
      if (mediaType.equalsIgnoreCase("String_Node_Str")) {
        offeredAudioEncodings=media.getMediaFormats(true);
        continue;
      }
    }
    Hashtable<String,List<String>> encodings=new Hashtable<String,List<String>>(2);
    encodings.put("String_Node_Str",offeredAudioEncodings);
    encodings.put("String_Node_Str",offeredVideoEncodings);
    encodings=intersectMediaEncodings(encodings);
    List<String> intersectedAudioEncsList=(List<String>)encodings.get("String_Node_Str");
    List<String> intersectedVideoEncsList=(List<String>)encodings.get("String_Node_Str");
    supportedAudioEncodings=intersectedAudioEncsList.toArray(new String[0]);
    supportedVideoEncodings=intersectedVideoEncsList.toArray(new String[0]);
  }
  Vector<MediaDescription> mediaDescs=new Vector<MediaDescription>();
  if (supportedAudioEncodings.length > 0) {
    MediaDescription am=mediaServCallback.getSdpFactory().createMediaDescription("String_Node_Str",publicAudioAddress.getPort(),1,"String_Node_Str",supportedAudioEncodings);
    String g723Str=String.valueOf(SdpConstants.G723);
    for (int i=0; i < supportedAudioEncodings.length; i++) {
      if (supportedAudioEncodings[i].equals(g723Str)) {
        am.setAttribute("String_Node_Str","String_Node_Str");
        am.setAttribute("String_Node_Str","String_Node_Str");
      }
    }
    byte onHold=this.onHold;
    if (!mediaServCallback.getDeviceConfiguration().isAudioCaptureSupported()) {
      onHold|=ON_HOLD_REMOTELY;
    }
    setAttributeOnHold(am,onHold);
    mediaDescs.add(am);
  }
  if (supportedVideoEncodings.length > 0) {
    MediaDescription vm=mediaServCallback.getSdpFactory().createMediaDescription("String_Node_Str",publicVideoAddress.getPort(),1,"String_Node_Str",supportedVideoEncodings);
    String h264Str=String.valueOf(Constants.H264_RTP_SDP);
    for (int i=0; i < supportedVideoEncodings.length; i++) {
      if (supportedVideoEncodings[i].equals(h264Str)) {
        vm.setAttribute("String_Node_Str",Constants.H264_RTP_SDP + "String_Node_Str");
        vm.setAttribute("String_Node_Str",Constants.H264_RTP_SDP + "String_Node_Str");
      }
    }
    byte onHold=this.onHold;
    if (!mediaServCallback.getDeviceConfiguration().isVideoCaptureSupported()) {
      onHold|=ON_HOLD_REMOTELY;
    }
    setAttributeOnHold(vm,onHold);
    mediaDescs.add(vm);
  }
  return mediaDescs;
}