Program: 103525
Project: 103525
Buggy source:
/** 
 * Initializes a new <tt>PortAudioAuto</tt> instance which creates PortAudio capture devices by enumerating all host devices with input channels.
 * @throws Exception if anything wrong happens while creating the PortAudiocapture devices
 */
PortAudioAuto() throws Exception {
  if (logger.isDebugEnabled())   Registry.set("String_Node_Str",true);
  int deviceCount=PortAudio.Pa_GetDeviceCount();
  int defaultInputDeviceIx=PortAudio.Pa_GetDefaultInputDevice();
  int defaultOutputDeviceIx=PortAudio.Pa_GetDefaultOutputDevice();
  Vector<CaptureDeviceInfo> playbackDevVector=new Vector<CaptureDeviceInfo>();
  int channels=1;
  int sampleSizeInBits=16;
  long sampleFormat=PortAudio.getPaSampleFormat(sampleSizeInBits);
  for (int deviceIndex=0; deviceIndex < deviceCount; deviceIndex++) {
    long deviceInfo=PortAudio.Pa_GetDeviceInfo(deviceIndex);
    int maxInputChannels=PortAudio.PaDeviceInfo_getMaxInputChannels(deviceInfo);
    int maxOutputChannels=PortAudio.PaDeviceInfo_getMaxOutputChannels(deviceInfo);
    String devName=PortAudio.PaDeviceInfo_getCharsetAwareName(deviceInfo);
    if (devName != null)     devName=devName.trim();
    CaptureDeviceInfo jmfInfo=new CaptureDeviceInfo(devName,new MediaLocator(LOCATOR_PROTOCOL + "String_Node_Str" + deviceIndex),new Format[]{new AudioFormat(AudioFormat.LINEAR,(maxInputChannels > 0) ? getSupportedSampleRate(true,deviceIndex,channels,sampleFormat) : PortAudio.DEFAULT_SAMPLE_RATE,sampleSizeInBits,channels,AudioFormat.LITTLE_ENDIAN,AudioFormat.SIGNED,Format.NOT_SPECIFIED,Format.NOT_SPECIFIED,Format.byteArray)});
    if (maxInputChannels > 0)     CaptureDeviceManager.addDevice(jmfInfo);
    if (maxOutputChannels > 0)     playbackDevVector.add(jmfInfo);
    if (deviceIndex == defaultInputDeviceIx)     defaultCaptureDevice=jmfInfo;
    if (deviceIndex == defaultOutputDeviceIx)     defaultPlaybackDevice=jmfInfo;
  }
  playbackDevices=playbackDevVector.toArray(new CaptureDeviceInfo[0]);
  CaptureDeviceManager.commit();
  DeviceConfiguration.addAudioSystem(DeviceConfiguration.AUDIO_SYSTEM_PORTAUDIO);
  try {
    ConfigurationService config=NeomediaActivator.getConfigurationService();
    boolean echoCancelEnabled=config.getBoolean(DeviceConfiguration.PROP_AUDIO_ECHOCANCEL_ENABLED,PortAudioManager.isEnabledEchoCancel());
    if (echoCancelEnabled) {
      long echoCancelFilterLengthInMillis=config.getLong(DeviceConfiguration.PROP_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS,PortAudioManager.getFilterLengthInMillis());
      PortAudioManager.setEchoCancel(echoCancelEnabled,echoCancelFilterLengthInMillis);
    }
    boolean denoiseEnabled=config.getBoolean(DeviceConfiguration.PROP_AUDIO_DENOISE_ENABLED,PortAudioManager.isEnabledDeNoise());
    PortAudioManager.setDeNoise(denoiseEnabled);
    int defaultAudioLatency=(int)(PortAudioManager.getSuggestedLatency() * 1000);
    int audioLatency=config.getInt(DeviceConfiguration.PROP_AUDIO_LATENCY,defaultAudioLatency);
    if (audioLatency != defaultAudioLatency)     PortAudioManager.setSuggestedLatency((double)audioLatency / 1000d);
  }
 catch (  Exception e) {
    logger.error("String_Node_Str",e);
  }
  supported=true;
}

Fixed version (ground truth):
/** 
 * Initializes a new <tt>PortAudioAuto</tt> instance which creates PortAudio capture devices by enumerating all host devices with input channels.
 * @throws Exception if anything wrong happens while creating the PortAudiocapture devices
 */
PortAudioAuto() throws Exception {
  if (logger.isDebugEnabled())   Registry.set("String_Node_Str",true);
  int deviceCount=PortAudio.Pa_GetDeviceCount();
  int defaultInputDeviceIx=PortAudio.Pa_GetDefaultInputDevice();
  int defaultOutputDeviceIx=PortAudio.Pa_GetDefaultOutputDevice();
  Vector<CaptureDeviceInfo> playbackDevVector=new Vector<CaptureDeviceInfo>();
  int channels=1;
  int sampleSizeInBits=16;
  long sampleFormat=PortAudio.getPaSampleFormat(sampleSizeInBits);
  for (int deviceIndex=0; deviceIndex < deviceCount; deviceIndex++) {
    long deviceInfo=PortAudio.Pa_GetDeviceInfo(deviceIndex);
    int maxInputChannels=PortAudio.PaDeviceInfo_getMaxInputChannels(deviceInfo);
    int maxOutputChannels=PortAudio.PaDeviceInfo_getMaxOutputChannels(deviceInfo);
    String devName=PortAudio.PaDeviceInfo_getCharsetAwareName(deviceInfo);
    if (devName != null)     devName=devName.trim();
    CaptureDeviceInfo jmfInfo=new CaptureDeviceInfo(devName,new MediaLocator(LOCATOR_PROTOCOL + "String_Node_Str" + deviceIndex),new Format[]{new AudioFormat(AudioFormat.LINEAR,(maxInputChannels > 0) ? getSupportedSampleRate(true,deviceIndex,channels,sampleFormat) : PortAudio.DEFAULT_SAMPLE_RATE,sampleSizeInBits,channels,AudioFormat.LITTLE_ENDIAN,AudioFormat.SIGNED,Format.NOT_SPECIFIED,Format.NOT_SPECIFIED,Format.byteArray)});
    if (maxInputChannels > 0)     CaptureDeviceManager.addDevice(jmfInfo);
    if (maxOutputChannels > 0)     playbackDevVector.add(jmfInfo);
    if (deviceIndex == defaultInputDeviceIx)     defaultCaptureDevice=jmfInfo;
    if (deviceIndex == defaultOutputDeviceIx)     defaultPlaybackDevice=jmfInfo;
  }
  playbackDevices=playbackDevVector.toArray(new CaptureDeviceInfo[0]);
  CaptureDeviceManager.commit();
  DeviceConfiguration.addAudioSystem(DeviceConfiguration.AUDIO_SYSTEM_PORTAUDIO);
  try {
    ConfigurationService config=NeomediaActivator.getConfigurationService();
    boolean echoCancelEnabled=config.getBoolean(DeviceConfiguration.PROP_AUDIO_ECHOCANCEL_ENABLED,PortAudioManager.isEnabledEchoCancel());
    long echoCancelFilterLengthInMillis=PortAudioManager.getFilterLengthInMillis();
    if (echoCancelEnabled) {
      echoCancelFilterLengthInMillis=config.getLong(DeviceConfiguration.PROP_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS,echoCancelFilterLengthInMillis);
    }
    PortAudioManager.setEchoCancel(echoCancelEnabled,echoCancelFilterLengthInMillis);
    boolean denoiseEnabled=config.getBoolean(DeviceConfiguration.PROP_AUDIO_DENOISE_ENABLED,PortAudioManager.isEnabledDeNoise());
    PortAudioManager.setDeNoise(denoiseEnabled);
    int defaultAudioLatency=(int)(PortAudioManager.getSuggestedLatency() * 1000);
    int audioLatency=config.getInt(DeviceConfiguration.PROP_AUDIO_LATENCY,defaultAudioLatency);
    if (audioLatency != defaultAudioLatency)     PortAudioManager.setSuggestedLatency((double)audioLatency / 1000d);
  }
 catch (  Exception ex) {
    logger.error("String_Node_Str",ex);
  }
  supported=true;
}