Program: 103425
Project: 103425
Buggy source:
/** 
 * Get a <tt>MediaDevice</tt> for a part of desktop streaming/sharing.
 * @param mediaDevice original desktop streaming <tt>MediaDevice</tt>
 * @param width width of the part
 * @param height height of the part
 * @param x origin of the x coordinate (relative to the full desktop)
 * @param y origin of the y coordinate (relative to the full desktop)
 * @return <tt>MediaDevice</tt> representing the part of desktop or nullif problem
 */
public MediaDevice getMediaDeviceForPartialDesktopStreaming(int width,int height,int x,int y){
  MediaDevice device=null;
  String name="String_Node_Str";
  Dimension size=null;
  int multiple=0;
  Point p=new Point(x,y);
  ScreenDevice dev=getScreenForPoint(p);
  int display=-1;
  if (dev != null) {
    display=dev.getIndex();
  }
 else {
    return null;
  }
  if (OSUtils.IS_MAC) {
    multiple=Math.round(width / 16f);
    width=multiple * 16;
  }
 else {
    multiple=Math.round(width / 2f);
    width=multiple * 2;
  }
  multiple=Math.round(height / 2f);
  height=multiple * 2;
  size=new Dimension(width,height);
  Format formats[]=new Format[]{new AVFrameFormat(size,Format.NOT_SPECIFIED,FFmpeg.PIX_FMT_ARGB,Format.NOT_SPECIFIED),new RGBFormat(size,Format.NOT_SPECIFIED,Format.byteArray,Format.NOT_SPECIFIED,32,2,3,4)};
  if (x < 0) {
    x+=dev.getSize().width;
  }
 else   if (x > dev.getSize().width) {
    List<ScreenDevice> devs=getAvailableScreenDevices();
    if (dev.getIndex() > 0) {
      dev=devs.get(dev.getIndex() - 1);
    }
    x-=dev.getSize().width;
  }
  if (y < 0) {
    y+=dev.getSize().height;
  }
 else   if (y > dev.getSize().height) {
    List<ScreenDevice> devs=getAvailableScreenDevices();
    if (dev.getIndex() > 0) {
      dev=devs.get(dev.getIndex() - 1);
    }
    y-=dev.getSize().height;
  }
  CaptureDeviceInfo devInfo=new CaptureDeviceInfo(name + "String_Node_Str" + display,new MediaLocator(ImageStreamingAuto.LOCATOR_PROTOCOL + "String_Node_Str" + display+ "String_Node_Str"+ x+ "String_Node_Str"+ y),formats);
  device=new MediaDeviceImpl(devInfo,MediaType.VIDEO);
  return device;
}

Fixed version (ground truth):
/** 
 * Get a <tt>MediaDevice</tt> for a part of desktop streaming/sharing.
 * @param mediaDevice original desktop streaming <tt>MediaDevice</tt>
 * @param width width of the part
 * @param height height of the part
 * @param x origin of the x coordinate (relative to the full desktop)
 * @param y origin of the y coordinate (relative to the full desktop)
 * @return <tt>MediaDevice</tt> representing the part of desktop or nullif problem
 */
public MediaDevice getMediaDeviceForPartialDesktopStreaming(int width,int height,int x,int y){
  MediaDevice device=null;
  String name="String_Node_Str";
  Dimension size=null;
  int multiple=0;
  Point p=new Point(x,y);
  ScreenDevice dev=getScreenForPoint(p);
  int display=-1;
  if (dev != null) {
    display=dev.getIndex();
  }
 else {
    return null;
  }
  if (OSUtils.IS_MAC) {
    multiple=Math.round(width / 16f);
    width=multiple * 16;
  }
 else {
    multiple=Math.round(width / 2f);
    width=multiple * 2;
  }
  multiple=Math.round(height / 2f);
  height=multiple * 2;
  size=new Dimension(width,height);
  Format formats[]=new Format[]{new AVFrameFormat(size,Format.NOT_SPECIFIED,FFmpeg.PIX_FMT_ARGB,Format.NOT_SPECIFIED),new RGBFormat(size,Format.NOT_SPECIFIED,Format.byteArray,Format.NOT_SPECIFIED,32,2,3,4)};
  Rectangle bounds=((ScreenDeviceImpl)dev).getBounds();
  x-=bounds.x;
  y-=bounds.y;
  CaptureDeviceInfo devInfo=new CaptureDeviceInfo(name + "String_Node_Str" + display,new MediaLocator(ImageStreamingAuto.LOCATOR_PROTOCOL + "String_Node_Str" + display+ "String_Node_Str"+ x+ "String_Node_Str"+ y),formats);
  device=new MediaDeviceImpl(devInfo,MediaType.VIDEO);
  return device;
}