Program: 107633
Project: 107633
Buggy source:
/** 
 * Implements the part of   {@link #doInitialize()} related to a specific<tt>IMMDevice</tt>.
 * @param iMMDevice the <tt>IMMDevice</tt> to initialize as part of theinvocation of <tt>doInitialize()</tt> on this instance
 * @throws HResultException if an error occurs while initializing thespecified <tt>iMMDevice</tt> in a native WASAPI function which returns an <tt>HRESULT</tt> value
 * @param captureDevices the state of the execution of<tt>doInitialize()</tt> which stores the <tt>CaptureDeviceInfo2</tt>s of the capture devices discovered by this <tt>WASAPISystem</tt>
 * @param playbackDevices the state of the execution of<tt>doInitialize()</tt> which stores the <tt>CaptureDeviceInfo2</tt>s of the playback devices discovered by this <tt>WASAPISystem</tt>
 */
private void doInitializeIMMDevice(long iMMDevice,List<CaptureDeviceInfo2> captureDevices,List<CaptureDeviceInfo2> playbackDevices) throws HResultException {
  String id=IMMDevice_GetId(iMMDevice);
  if (id == null)   throw new RuntimeException("String_Node_Str");
  long iAudioClient=IMMDevice_Activate(iMMDevice,IID_IAudioClient,CLSCTX_ALL,0);
  List<AudioFormat> formats;
  if (iAudioClient == 0)   throw new RuntimeException("String_Node_Str");
  try {
    formats=getIAudioClientSupportedFormats(iAudioClient);
  }
  finally {
    IAudioClient_Release(iAudioClient);
  }
  if ((formats != null) && !formats.isEmpty()) {
    String name=null;
    try {
      name=getIMMDeviceFriendlyName(iMMDevice);
    }
 catch (    Throwable t) {
      if (t instanceof ThreadDeath)       throw (ThreadDeath)t;
      logger.warn("String_Node_Str" + "String_Node_Str" + id,t);
    }
    if ((name == null) || (name.length() == 0))     name=id;
    int dataFlow=getIMMDeviceDataFlow(iMMDevice);
    List<CaptureDeviceInfo2> devices;
switch (dataFlow) {
case eCapture:
      List<AudioFormat> aecSupportedFormats=getAECSupportedFormats();
    if (!aecSupportedFormats.isEmpty()) {
      for (      AudioFormat format : aecSupportedFormats)       if (!formats.contains(format))       formats.add(format);
    }
  devices=captureDevices;
break;
case eRender:
devices=playbackDevices;
break;
default :
devices=null;
logger.error("String_Node_Str" + id);
break;
}
if (devices != null) {
CaptureDeviceInfo2 cdi2=new CaptureDeviceInfo2(name,new MediaLocator(LOCATOR_PROTOCOL + "String_Node_Str" + id),formats.toArray(new Format[formats.size()]),id,null,null);
devices.add(cdi2);
}
}
}

Fixed version (ground truth):
/** 
 * Implements the part of   {@link #doInitialize()} related to a specific<tt>IMMDevice</tt>.
 * @param iMMDevice the <tt>IMMDevice</tt> to initialize as part of theinvocation of <tt>doInitialize()</tt> on this instance
 * @throws HResultException if an error occurs while initializing thespecified <tt>iMMDevice</tt> in a native WASAPI function which returns an <tt>HRESULT</tt> value
 * @param captureDevices the state of the execution of<tt>doInitialize()</tt> which stores the <tt>CaptureDeviceInfo2</tt>s of the capture devices discovered by this <tt>WASAPISystem</tt>
 * @param playbackDevices the state of the execution of<tt>doInitialize()</tt> which stores the <tt>CaptureDeviceInfo2</tt>s of the playback devices discovered by this <tt>WASAPISystem</tt>
 */
private void doInitializeIMMDevice(long iMMDevice,List<CaptureDeviceInfo2> captureDevices,List<CaptureDeviceInfo2> playbackDevices) throws HResultException {
  String id=IMMDevice_GetId(iMMDevice);
  if (id == null)   throw new RuntimeException("String_Node_Str");
  long iAudioClient=IMMDevice_Activate(iMMDevice,IID_IAudioClient,CLSCTX_ALL,0);
  List<AudioFormat> formats;
  if (iAudioClient == 0)   throw new RuntimeException("String_Node_Str");
  try {
    formats=getIAudioClientSupportedFormats(iAudioClient);
  }
  finally {
    IAudioClient_Release(iAudioClient);
  }
  if ((formats != null) && !formats.isEmpty()) {
    String name=null;
    try {
      name=getIMMDeviceFriendlyName(iMMDevice);
    }
 catch (    Throwable t) {
      if (t instanceof ThreadDeath)       throw (ThreadDeath)t;
      logger.warn("String_Node_Str" + "String_Node_Str" + id,t);
    }
    if ((name == null) || (name.length() == 0))     name=id;
    int dataFlow=getIMMDeviceDataFlow(iMMDevice);
    List<CaptureDeviceInfo2> devices;
switch (dataFlow) {
case eCapture:
      devices=captureDevices;
    break;
case eRender:
  devices=playbackDevices;
break;
default :
devices=null;
logger.error("String_Node_Str" + id);
break;
}
if (devices != null) {
configureSupportedFormats(dataFlow,formats);
if (!formats.isEmpty()) {
CaptureDeviceInfo2 cdi2=new CaptureDeviceInfo2(name,new MediaLocator(LOCATOR_PROTOCOL + "String_Node_Str" + id),formats.toArray(new Format[formats.size()]),id,null,null);
devices.add(cdi2);
}
}
}
}