nus-yam/ex-repair huggingface dataset:
Program: 150576
Project: 150576
Buggy source:
private BundleAdjustmentObservations createObservations(BundleAdjustmentSceneStructure structure){
  BundleAdjustmentObservations obs=new BundleAdjustmentObservations(structure.views.length);
  for (int j=0; j < structure.points.length; j++) {
    BundleAdjustmentSceneStructure.Point p=structure.points[j];
    for (int i=0; i < p.views.size; i++) {
      BundleAdjustmentObservations.View v=obs.getView(p.views.get(i));
      v.feature.add(j);
      v.observations.add(rand.nextInt(300) + 20);
      v.observations.add(rand.nextInt(300) + 20);
    }
  }
  return obs;
}

Fixed version (ground truth):
public static BundleAdjustmentObservations createObservations(Random rand,BundleAdjustmentSceneStructure structure){
  BundleAdjustmentObservations obs=new BundleAdjustmentObservations(structure.views.length);
  for (int j=0; j < structure.points.length; j++) {
    BundleAdjustmentSceneStructure.Point p=structure.points[j];
    for (int i=0; i < p.views.size; i++) {
      BundleAdjustmentObservations.View v=obs.getView(p.views.get(i));
      v.feature.add(j);
      v.observations.add(rand.nextInt(300) + 20);
      v.observations.add(rand.nextInt(300) + 20);
    }
  }
  return obs;
}
Program: 150577
Project: 150577
Buggy source:
/** 
 * Makes sure that when given the same input it produces the same output
 */
@Test public void multipleCalls(){
  BundleAdjustmentSceneStructure structure=createScene(rand);
  BundleAdjustmentObservations obs=createObservations(structure);
  double param[]=new double[structure.getParameterCount()];
  new CodecBundleAdjustmentSceneStructure().encode(structure,param);
  BundleAdjustmentResidualFunction alg=new BundleAdjustmentResidualFunction();
  alg.configure(structure,obs);
  double[] expected=new double[alg.getNumOfOutputsM()];
  double[] found=new double[alg.getNumOfOutputsM()];
  alg.process(param,expected);
  alg.process(param,found);
  assertArrayEquals(expected,found,UtilEjml.TEST_F64);
}

Fixed version (ground truth):
/** 
 * Makes sure that when given the same input it produces the same output
 */
@Test public void multipleCalls(){
  BundleAdjustmentSceneStructure structure=createScene(rand);
  BundleAdjustmentObservations obs=createObservations(rand,structure);
  double param[]=new double[structure.getParameterCount()];
  new CodecBundleAdjustmentSceneStructure().encode(structure,param);
  BundleAdjustmentResidualFunction alg=new BundleAdjustmentResidualFunction();
  alg.configure(structure,obs);
  double[] expected=new double[alg.getNumOfOutputsM()];
  double[] found=new double[alg.getNumOfOutputsM()];
  alg.process(param,expected);
  alg.process(param,found);
  assertArrayEquals(expected,found,UtilEjml.TEST_F64);
}
Program: 150578
Project: 150578
Buggy source:
/** 
 * Closes the camera. Returns true if the camera was not already closed and it closed it
 * @return
 */
protected boolean closeCamera(){
  if (verbose)   Log.i(TAG,"String_Node_Str");
  if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
    throw new RuntimeException("String_Node_Str");
  }
  boolean closed=false;
  if (verbose) {
    StackTraceElement[] trace=new RuntimeException().getStackTrace();
    for (int i=0; i < Math.min(trace.length,3); i++) {
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ trace[i].toString());
    }
  }
  try {
    open.mLock.lock();
    if (verbose)     Log.i(TAG,"String_Node_Str" + (open.mCameraDevice == null));
    closePreviewSession();
    if (null != open.mCameraDevice) {
      closed=true;
      open.mCameraDevice.close();
      open.mCameraDevice=null;
    }
    open.mCameraSize=null;
    open.mCameraCharacterstics=null;
  }
  finally {
    open.mLock.unlock();
  }
  return closed;
}

Fixed version (ground truth):
/** 
 * Closes the camera. Returns true if the camera was not already closed and it closed it
 * @return
 */
protected boolean closeCamera(){
  if (verbose)   Log.i(TAG,"String_Node_Str");
  if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
    throw new RuntimeException("String_Node_Str");
  }
  boolean closed=false;
  if (verbose) {
    StackTraceElement[] trace=new RuntimeException().getStackTrace();
    for (int i=0; i < Math.min(trace.length,3); i++) {
      System.out.println("String_Node_Str" + i + "String_Node_Str"+ trace[i].toString());
    }
  }
  open.mLock.lock();
  try {
    if (verbose)     Log.i(TAG,"String_Node_Str" + (open.mCameraDevice == null) + "String_Node_Str"+ open.state);
    closePreviewSession();
    if (open.state == CameraState.OPENING) {
      open.state=CameraState.CLOSING;
      if (open.mCameraDevice != null) {
        throw new RuntimeException("String_Node_Str");
      }
    }
 else {
      if (null != open.mCameraDevice) {
        closed=true;
        open.mCameraDevice.close();
        open.mCameraDevice=null;
      }
      open.state=CameraState.CLOSED;
      open.mCameraSize=null;
      open.mCameraCharacterstics=null;
    }
  }
  finally {
    open.mLock.unlock();
  }
  return closed;
}
Program: 150579
Project: 150579
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  displayMetrics=Resources.getSystem().getDisplayMetrics();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  if (verbose)   Log.i(TAG,"String_Node_Str");
  super.onCreate(savedInstanceState);
  displayMetrics=Resources.getSystem().getDisplayMetrics();
}
Program: 150581
Project: 150581
Buggy source:
/** 
 * Re-opens the camera with the same settings at the specified resolution. It is assumed that you know what you're doing and that this is a valid resolution. WARNING: UNTESTED
 */
protected void reopenCameraAtResolution(int cameraWidth,int cameraHeight){
  boolean releaseLock=true;
  try {
    open.mLock.lock();
    if (verbose)     Log.i(TAG,"String_Node_Str" + (open.mCameraDevice == null));
    if (null == open.mCameraDevice) {
      throw new RuntimeException("String_Node_Str");
    }
    closePreviewSession();
    open.mCameraSize=null;
    open.mCameraCharacterstics=null;
    firstFrame=true;
    CameraManager manager=(CameraManager)getSystemService(Context.CAMERA_SERVICE);
    if (manager == null)     throw new RuntimeException("String_Node_Str");
    try {
      mPreviewReader=ImageReader.newInstance(cameraWidth,cameraHeight,ImageFormat.YUV_420_888,2);
      mPreviewReader.setOnImageAvailableListener(onAvailableListener,mBackgroundHandler);
      configureTransform(viewWidth,viewHeight);
      manager.openCamera(open.cameraId,mStateCallback,null);
      releaseLock=false;
    }
 catch (    IllegalArgumentException e) {
      Toast.makeText(this,e.getMessage(),Toast.LENGTH_LONG).show();
      finish();
    }
catch (    CameraAccessException e) {
      e.printStackTrace();
    }
  }
  finally {
    if (releaseLock)     open.mLock.unlock();
  }
}

Fixed version (ground truth):
/** 
 * Re-opens the camera with the same settings at the specified resolution. It is assumed that you know what you're doing and that this is a valid resolution. WARNING: UNTESTED
 */
protected void reopenCameraAtResolution(int cameraWidth,int cameraHeight){
  if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
    throw new RuntimeException("String_Node_Str");
  }
  boolean releaseLock=true;
  open.mLock.lock();
  try {
    if (verbose)     Log.i(TAG,"String_Node_Str" + (open.mCameraDevice == null) + "String_Node_Str"+ open.state);
    if (open.state != CameraState.OPEN)     throw new RuntimeException("String_Node_Str");
    if (null == open.mCameraDevice) {
      throw new RuntimeException("String_Node_Str");
    }
    closePreviewSession();
    open.mCameraSize=null;
    open.mCameraCharacterstics=null;
    firstFrame=true;
    CameraManager manager=(CameraManager)getSystemService(Context.CAMERA_SERVICE);
    if (manager == null)     throw new RuntimeException("String_Node_Str");
    try {
      mPreviewReader=ImageReader.newInstance(cameraWidth,cameraHeight,ImageFormat.YUV_420_888,2);
      mPreviewReader.setOnImageAvailableListener(onAvailableListener,mBackgroundHandler);
      configureTransform(viewWidth,viewHeight);
      manager.openCamera(open.cameraId,mStateCallback,null);
      releaseLock=false;
    }
 catch (    IllegalArgumentException e) {
      Toast.makeText(this,e.getMessage(),Toast.LENGTH_LONG).show();
      finish();
    }
catch (    CameraAccessException e) {
      e.printStackTrace();
    }
  }
  finally {
    if (releaseLock)     open.mLock.unlock();
  }
}
Program: 150583
Project: 150583
Buggy source:
@Override public int getFormat(){
  return 0;
}

Fixed version (ground truth):
@Override public int getFormat(){
  return ImageFormat.YUV_420_888;
}
Program: 150584
Project: 150584
Buggy source:
public static Planar<GrayU8> yuvToPlanarYuvU8(Image yuv,Planar<GrayU8> output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.setNumberOfBands(3);
    output.reshape(width,height);
  }
 else {
    output=new Planar(GrayU8.class,width,height,3);
  }
  final byte[] dataY=output.getBand(0).data;
  final byte[] dataU=output.getBand(1).data;
  final byte[] dataV=output.getBand(2).data;
  ProcessorYuv processor=new ProcessorYuv(){
    int indexOut=0;
    @Override final public void processYUV(    final int y,    final int u,    final int v){
      dataY[indexOut]=(byte)y;
      dataU[indexOut]=(byte)u;
      dataV[indexOut++]=(byte)v;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}

Fixed version (ground truth):
public static Planar<GrayU8> yuvToPlanarYuvU8(Image yuv,Planar<GrayU8> output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.reshape(width,height,3);
  }
 else {
    output=new Planar(GrayU8.class,width,height,3);
  }
  final byte[] dataY=output.getBand(0).data;
  final byte[] dataU=output.getBand(1).data;
  final byte[] dataV=output.getBand(2).data;
  ProcessorYuv processor=new ProcessorYuv(){
    int indexOut=0;
    @Override final public void processYUV(    final int y,    final int u,    final int v){
      dataY[indexOut]=(byte)y;
      dataU[indexOut]=(byte)u;
      dataV[indexOut++]=(byte)v;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}
Program: 150585
Project: 150585
Buggy source:
public static Planar<GrayF32> yuvToPlanarRgbF32(Image yuv,Planar<GrayF32> output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.setNumberOfBands(3);
    output.reshape(width,height);
  }
 else {
    output=new Planar<>(GrayF32.class,width,height,3);
  }
  final float[] red=output.getBand(0).data;
  final float[] green=output.getBand(1).data;
  final float[] blue=output.getBand(2).data;
  ProcessorYuv processor=new ProcessorYuvRgb(){
    int indexOut=0;
    @Override public void processRGB(    final int r,    final int g,    final int b){
      red[indexOut]=r;
      green[indexOut]=g;
      blue[indexOut++]=b;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}

Fixed version (ground truth):
public static Planar<GrayF32> yuvToPlanarRgbF32(Image yuv,Planar<GrayF32> output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.reshape(width,height,3);
  }
 else {
    output=new Planar<>(GrayF32.class,width,height,3);
  }
  final float[] red=output.getBand(0).data;
  final float[] green=output.getBand(1).data;
  final float[] blue=output.getBand(2).data;
  ProcessorYuv processor=new ProcessorYuvRgb(){
    int indexOut=0;
    @Override public void processRGB(    final int r,    final int g,    final int b){
      red[indexOut]=r;
      green[indexOut]=g;
      blue[indexOut++]=b;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}
Program: 150587
Project: 150587
Buggy source:
public static Planar<GrayU8> yuvToPlanarRgbU8(Image yuv,Planar<GrayU8> output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.setNumberOfBands(3);
    output.reshape(width,height);
  }
 else {
    output=new Planar<>(GrayU8.class,width,height,3);
  }
  final byte[] red=output.getBand(0).data;
  final byte[] green=output.getBand(1).data;
  final byte[] blue=output.getBand(2).data;
  ProcessorYuv processor=new ProcessorYuvRgb(){
    int indexOut=0;
    @Override public void processRGB(    final int r,    final int g,    final int b){
      red[indexOut]=(byte)r;
      green[indexOut]=(byte)g;
      blue[indexOut++]=(byte)b;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}

Fixed version (ground truth):
public static Planar<GrayU8> yuvToPlanarRgbU8(Image yuv,Planar<GrayU8> output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.reshape(width,height,3);
  }
 else {
    output=new Planar<>(GrayU8.class,width,height,3);
  }
  final byte[] red=output.getBand(0).data;
  final byte[] green=output.getBand(1).data;
  final byte[] blue=output.getBand(2).data;
  ProcessorYuv processor=new ProcessorYuvRgb(){
    int indexOut=0;
    @Override public void processRGB(    final int r,    final int g,    final int b){
      red[indexOut]=(byte)r;
      green[indexOut]=(byte)g;
      blue[indexOut++]=(byte)b;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}
Program: 150588
Project: 150588
Buggy source:
public static InterleavedU8 yuvToInterleavedRgbU8(Image yuv,InterleavedU8 output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.setNumberOfBands(3);
    output.reshape(width,height);
  }
 else {
    output=new InterleavedU8(width,height,3);
  }
  InterleavedU8 _output=output;
  ProcessorYuv processor=new ProcessorYuvRgb(){
    int indexOut=0;
    @Override public void processRGB(    final int r,    final int g,    final int b){
      _output.data[indexOut++]=(byte)r;
      _output.data[indexOut++]=(byte)g;
      _output.data[indexOut++]=(byte)b;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}

Fixed version (ground truth):
public static InterleavedU8 yuvToInterleavedRgbU8(Image yuv,InterleavedU8 output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.reshape(width,height,3);
  }
 else {
    output=new InterleavedU8(width,height,3);
  }
  InterleavedU8 _output=output;
  ProcessorYuv processor=new ProcessorYuvRgb(){
    int indexOut=0;
    @Override public void processRGB(    final int r,    final int g,    final int b){
      _output.data[indexOut++]=(byte)r;
      _output.data[indexOut++]=(byte)g;
      _output.data[indexOut++]=(byte)b;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}
Program: 150589
Project: 150589
Buggy source:
public static InterleavedF32 yuvToInterleavedRgbF32(Image yuv,InterleavedF32 output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.setNumberOfBands(3);
    output.reshape(width,height);
  }
 else {
    output=new InterleavedF32(width,height,3);
  }
  InterleavedF32 _output=output;
  ProcessorYuv processor=new ProcessorYuvRgb(){
    int indexOut=0;
    @Override public void processRGB(    final int r,    final int g,    final int b){
      _output.data[indexOut++]=r;
      _output.data[indexOut++]=g;
      _output.data[indexOut++]=b;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}

Fixed version (ground truth):
public static InterleavedF32 yuvToInterleavedRgbF32(Image yuv,InterleavedF32 output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.reshape(width,height,3);
  }
 else {
    output=new InterleavedF32(width,height,3);
  }
  InterleavedF32 _output=output;
  ProcessorYuv processor=new ProcessorYuvRgb(){
    int indexOut=0;
    @Override public void processRGB(    final int r,    final int g,    final int b){
      _output.data[indexOut++]=r;
      _output.data[indexOut++]=g;
      _output.data[indexOut++]=b;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}
Program: 150590
Project: 150590
Buggy source:
public static InterleavedU8 yuvToInterleavedYuvU8(Image yuv,InterleavedU8 output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.setNumberOfBands(3);
    output.reshape(width,height);
  }
 else {
    output=new InterleavedU8(width,height,3);
  }
  final byte[] data=output.data;
  ProcessorYuv processor=new ProcessorYuv(){
    int indexOut=0;
    @Override final public void processYUV(    final int y,    final int u,    final int v){
      data[indexOut++]=(byte)y;
      data[indexOut++]=(byte)u;
      data[indexOut++]=(byte)v;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}

Fixed version (ground truth):
public static InterleavedU8 yuvToInterleavedYuvU8(Image yuv,InterleavedU8 output,byte work[]){
  int width=yuv.getWidth();
  int height=yuv.getHeight();
  if (output != null) {
    output.reshape(width,height,3);
  }
 else {
    output=new InterleavedU8(width,height,3);
  }
  final byte[] data=output.data;
  ProcessorYuv processor=new ProcessorYuv(){
    int indexOut=0;
    @Override final public void processYUV(    final int y,    final int u,    final int v){
      data[indexOut++]=(byte)y;
      data[indexOut++]=(byte)u;
      data[indexOut++]=(byte)v;
    }
  }
;
  processYuv(yuv,work,processor);
  return output;
}
Program: 150597
Project: 150597
Buggy source:
/** 
 * Determine the QR code's version. For QR codes version < 7 it can be determined using the marker's size alone. Otherwise the version is read from the image itself
 * @return true if version was successfully extracted or false if it failed
 */
private boolean extractVersionInfo(QrCode qr){
  int version=estimateVersionBySize(qr);
  if (version >= QrCode.VERSION_ENCODED_AT) {
    readVersionRegion0(qr);
    int version0=decodeVersion();
    readVersionRegion1(qr);
    int version1=decodeVersion();
    if (version0 < 1 && version1 < 1) {
      version=-1;
    }
 else     if (version0 < 1) {
      version=version1;
    }
 else     if (version1 < 1) {
      version=version0;
    }
 else     if (version0 != version1) {
      version=-1;
    }
 else {
      version=version0;
    }
  }
 else   if (version <= 0) {
    qr.version=-1;
  }
  qr.version=version;
  return version != -1;
}

Fixed version (ground truth):
/** 
 * Determine the QR code's version. For QR codes version < 7 it can be determined using the marker's size alone. Otherwise the version is read from the image itself
 * @return true if version was successfully extracted or false if it failed
 */
boolean extractVersionInfo(QrCode qr){
  int version=estimateVersionBySize(qr);
  if (version >= QrCode.VERSION_ENCODED_AT) {
    readVersionRegion0(qr);
    int version0=decodeVersion();
    readVersionRegion1(qr);
    int version1=decodeVersion();
    if (version0 < 1 && version1 < 1) {
      version=-1;
    }
 else     if (version0 < 1) {
      version=version1;
    }
 else     if (version1 < 1) {
      version=version0;
    }
 else     if (version0 != version1) {
      version=-1;
    }
 else {
      version=version0;
    }
  }
 else   if (version <= 0) {
    version=-1;
  }
  qr.version=version;
  return version >= 1 && version <= QrCode.MAX_VERSION;
}
Program: 150598
Project: 150598
Buggy source:
/** 
 * Decode version information from read in bits
 * @return The found version or -1 if it failed
 */
private int decodeVersion(){
  int bitField=this.bits.read(0,18,false);
  int message;
  if (QrCodePolynomialMath.checkVersionBits(bitField)) {
    message=bitField >> 12;
  }
 else {
    message=QrCodePolynomialMath.correctVersionBits(bitField);
  }
  if (message > QrCode.MAX_VERSION || message < QrCode.VERSION_ENCODED_AT)   return -1;
  return message;
}

Fixed version (ground truth):
/** 
 * Decode version information from read in bits
 * @return The found version or -1 if it failed
 */
int decodeVersion(){
  int bitField=this.bits.read(0,18,false);
  int message;
  if (QrCodePolynomialMath.checkVersionBits(bitField)) {
    message=bitField >> 12;
  }
 else {
    message=QrCodePolynomialMath.correctVersionBits(bitField);
  }
  if (message > QrCode.MAX_VERSION || message < QrCode.VERSION_ENCODED_AT)   return -1;
  return message;
}
Program: 150599
Project: 150599
Buggy source:
/** 
 * Attempts to estimate the qr-code's version based on distance between position patterns. If it can't estimate it based on distance return -1
 */
private int estimateVersionBySize(QrCode qr){
  gridReader.setSquare(qr.ppCorner,0);
  gridReader.imageToGrid(qr.ppRight.get(0),grid);
  if (Math.abs(grid.y) >= 1)   return -1;
  double versionX=((grid.x + 7) - 17) / 4;
  gridReader.imageToGrid(qr.ppDown.get(0),grid);
  if (Math.abs(grid.x) >= 1)   return -1;
  double versionY=((grid.y + 7) - 17) / 4;
  if (Math.abs(versionX - versionY) > 1.5)   return -1;
  return (int)((versionX + versionY) / 2.0 + 0.5);
}

Fixed version (ground truth):
/** 
 * Attempts to estimate the qr-code's version based on distance between position patterns. If it can't estimate it based on distance return -1
 */
int estimateVersionBySize(QrCode qr){
  gridReader.setSquare(qr.ppCorner,0);
  gridReader.imageToGrid(qr.ppRight.get(0),grid);
  if (Math.abs(grid.y) >= 1)   return -1;
  double versionX=((grid.x + 7) - 17) / 4;
  gridReader.imageToGrid(qr.ppDown.get(0),grid);
  if (Math.abs(grid.x) >= 1)   return -1;
  double versionY=((grid.y + 7) - 17) / 4;
  if (Math.abs(versionX - versionY) > 1.5)   return -1;
  return (int)((versionX + versionY) / 2.0 + 0.5);
}
Program: 150600
Project: 150600
Buggy source:
@Override public void configureBeforePolyline(PointsToPolyline contourToPolyline,boolean touchesBorder){
  if (touchesBorder) {
    contourToPolyline.setMinimumSides(3);
    contourToPolyline.setMaximumSides(8);
  }
 else {
    contourToPolyline.setMinimumSides(4);
    contourToPolyline.setMaximumSides(4);
  }
}

Fixed version (ground truth):
@Override public void configureBeforePolyline(PointsToPolyline contourToPolyline,boolean touchesBorder){
  if (touchesBorder) {
    contourToPolyline.setConvex(false);
    contourToPolyline.setMinimumSides(3);
    contourToPolyline.setMaximumSides(8);
  }
 else {
    contourToPolyline.setConvex(true);
    contourToPolyline.setMinimumSides(4);
    contourToPolyline.setMaximumSides(4);
  }
}
Program: 150601
Project: 150601
Buggy source:
@Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture,int width,int height){
  openCamera(width,height);
}

Fixed version (ground truth):
@Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture,int width,int height){
  if (verbose)   Log.i(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str"+ (mCameraSize != null));
  openCamera(width,height);
}
Program: 150602
Project: 150602
Buggy source:
@Override public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture,int width,int height){
  configureTransform(width,height);
}

Fixed version (ground truth):
@Override public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture,int width,int height){
  if (verbose)   Log.i(TAG,"String_Node_Str" + width + "String_Node_Str"+ height);
  configureTransform(width,height);
}
Program: 150603
Project: 150603
Buggy source:
@Override public void onLayoutChange(View view,int left,int top,int right,int bottom,int leftWas,int topWas,int rightWas,int bottomWas){
  int width=right - left;
  int height=bottom - top;
  if (mCameraSize == null) {
    openCamera(width,height);
  }
  view.removeOnLayoutChangeListener(this);
}

Fixed version (ground truth):
@Override public void onLayoutChange(View view,int left,int top,int right,int bottom,int leftWas,int topWas,int rightWas,int bottomWas){
  int width=right - left;
  int height=bottom - top;
  if (verbose)   Log.i(TAG,"String_Node_Str" + top + "String_Node_Str"+ left+ "String_Node_Str"+ width+ "String_Node_Str"+ height+ "String_Node_Str"+ (mCameraSize != null));
  if (mCameraSize == null) {
    openCamera(width,height);
  }
  view.removeOnLayoutChangeListener(this);
}
Program: 150604
Project: 150604
Buggy source:
/** 
 * Called when the camera's resolution has changed.
 */
protected void onCameraResolutionChange(int width,int height){
  if (verbose)   Log.i(TAG,"String_Node_Str" + width + "String_Node_Str"+ height+ "String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Called when the camera's resolution has changed.
 */
protected void onCameraResolutionChange(int cameraWidth,int cameraHeight){
  if (verbose)   Log.i(TAG,"String_Node_Str" + cameraWidth + "String_Node_Str"+ cameraHeight+ "String_Node_Str");
}
Program: 150605
Project: 150605
Buggy source:
/** 
 * Renders the visualizations. Override and invoke super to add your own
 */
protected void onDrawFrame(SurfaceView view,Canvas canvas){
  if (showBitmap) {
synchronized (bitmapLock) {
      canvas.drawBitmap(bitmap,imageToView,null);
    }
  }
}

Fixed version (ground truth):
/** 
 * Renders the visualizations. Override and invoke super to add your own
 */
protected void onDrawFrame(SurfaceView view,Canvas canvas){
  canvas.setMatrix(identity);
  if (showBitmap) {
synchronized (bitmapLock) {
      canvas.drawBitmap(bitmap,imageToView,null);
    }
  }
}
Program: 150606
Project: 150606
Buggy source:
/** 
 * Internal function which manages images and invokes   {@link #processImage}.
 */
private void processImageOuter(ImageBase image){
  long startTime=System.currentTimeMillis();
  processImage(image);
  if (!visualizeOnlyMostRecent || startTime > timeOfLastUpdated) {
    timeOfLastUpdated=startTime;
    if (showBitmap) {
synchronized (bitmapLock) {
        ConvertBitmap.boofToBitmap(image,bitmap,bitmapTmp);
      }
    }
    runOnUiThread(() -> displayView.invalidate());
  }
synchronized (imageLock) {
    if (imageType.getFamily() != image.getImageType().getFamily())     return;
    if (imageType.getDataType() != image.getImageType().getDataType())     return;
    if (imageType.getNumBands() != image.getImageType().getNumBands())     return;
    stackImages.add(image);
  }
}

Fixed version (ground truth):
/** 
 * Internal function which manages images and invokes   {@link #processImage}.
 */
private void processImageOuter(ImageBase image){
  long startTime=System.currentTimeMillis();
  processImage(image);
  if (!visualizeOnlyMostRecent || startTime > timeOfLastUpdated) {
    timeOfLastUpdated=startTime;
    if (showBitmap) {
synchronized (bitmapLock) {
        ConvertBitmap.boofToBitmap(image,bitmap,bitmapTmp);
      }
    }
    runOnUiThread(() -> displayView.invalidate());
  }
synchronized (imageLock) {
    if (imageType.isSameType(image.getImageType()))     stackImages.add(image);
  }
}
Program: 150608
Project: 150608
Buggy source:
/** 
 * Solves the IPPE problem
 */
protected void IPPE(DMatrixRMaj R1,DMatrixRMaj R2){
  compute_Kv();
  compute_B(B,R_v,v1,v2);
  CommonOps_DDF2.invert(B,B);
  CommonOps_DDF2.mult(B,J,A);
  double gamma=largestSingularValue(A);
  CommonOps_DDF2.scale(1.0 / gamma,A,R22);
  CommonOps_DDF2.setIdentity(B);
  CommonOps_DDF2.multAddTransA(-1,R22,R22,B);
  double b1=Math.sqrt(B.a11);
  double b2=Math.signum(B.a12) * Math.sqrt(B.a22);
  l0.set(R22.a11,R22.a12,b1);
  l1.set(R22.a21,R22.a22,b2);
  l0.cross(l1,ca);
  constructR(R1,R_v,R22,b1,b2,ca,1,tmp);
  constructR(R2,R_v,R22,b1,b2,ca,1,tmp);
}

Fixed version (ground truth):
/** 
 * Solves the IPPE problem
 */
protected void IPPE(DMatrixRMaj R1,DMatrixRMaj R2){
  double norm_v=Math.sqrt(v1 * v1 + v2 * v2);
  if (norm_v <= UtilEjml.EPS) {
    CommonOps_DDRM.setIdentity(R_v);
  }
 else {
    compute_Rv();
  }
  compute_B(B,R_v,v1,v2);
  CommonOps_DDF2.invert(B,B);
  CommonOps_DDF2.mult(B,J,A);
  double gamma=largestSingularValue2x2(A);
  CommonOps_DDF2.scale(1.0 / gamma,A,R22);
  CommonOps_DDF2.setIdentity(B);
  CommonOps_DDF2.multAddTransA(-1,R22,R22,B);
  double b1=Math.sqrt(B.a11);
  double b2=Math.signum(B.a12) * Math.sqrt(B.a22);
  l0.set(R22.a11,R22.a12,b1);
  l1.set(R22.a21,R22.a22,b2);
  l0.cross(l1,ca);
  constructR(R1,R_v,R22,b1,b2,ca,1,tmp);
  constructR(R2,R_v,R22,b1,b2,ca,1,tmp);
}
Program: 150610
Project: 150610
Buggy source:
/** 
 * Draws the estimated value of each bit onto the image
 */
private void renderBinaryValues(Graphics2D g2,QrCode qr){
  locatorB.setMarker(qr);
  List<Point2D_I32> points=QrCode.LOCATION_BITS[qr.version];
  PackedBits8 bits=new PackedBits8();
  bits.data=qr.rawbits;
  bits.size=qr.rawbits.length * 8;
  Point2D_F32 p=new Point2D_F32();
  g2.setStroke(new BasicStroke(1));
  for (int i=0; i < bits.size; i++) {
    Point2D_I32 c=points.get(i);
    locatorB.gridToImage(c.y + 0.5f,c.x + 0.5f,p);
    int value=qr.mask.apply(c.y,c.x,bits.get(i));
    if (value == 1) {
      renderCircleAt(g2,p,Color.BLACK,Color.LIGHT_GRAY);
    }
 else     if (value == 0) {
      renderCircleAt(g2,p,Color.WHITE,Color.LIGHT_GRAY);
    }
 else {
      renderCircleAt(g2,p,Color.RED,Color.LIGHT_GRAY);
    }
  }
}

Fixed version (ground truth):
/** 
 * Draws the estimated value of each bit onto the image
 */
private void renderBinaryValues(Graphics2D g2,QrCode qr){
  locator.setMarker(qr);
  List<Point2D_I32> points=QrCode.LOCATION_BITS[qr.version];
  PackedBits8 bits=new PackedBits8();
  bits.data=qr.rawbits;
  bits.size=qr.rawbits.length * 8;
  Point2D_F32 p=new Point2D_F32();
  g2.setStroke(new BasicStroke(1));
  for (int i=0; i < bits.size; i++) {
    Point2D_I32 c=points.get(i);
    locator.gridToImage(c.y + 0.5f,c.x + 0.5f,p);
    int value=qr.mask.apply(c.y,c.x,bits.get(i));
    if (value == 1) {
      renderCircleAt(g2,p,Color.BLACK,Color.LIGHT_GRAY);
    }
 else     if (value == 0) {
      renderCircleAt(g2,p,Color.WHITE,Color.LIGHT_GRAY);
    }
 else {
      renderCircleAt(g2,p,Color.RED,Color.LIGHT_GRAY);
    }
  }
}
Program: 150611
Project: 150611
Buggy source:
/** 
 * Override this function so that it doesn't threshold the image twice
 */
@Override public void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  System.out.flush();
  original=ConvertBufferedImage.checkCopy(buffered,original);
  work=ConvertBufferedImage.checkDeclare(buffered,work);
  final double timeInSeconds;
synchronized (this) {
    long before=System.nanoTime();
    detector.process((T)input);
    long after=System.nanoTime();
    timeInSeconds=(after - before) * 1e-9;
  }
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      controls.setProcessingTime(timeInSeconds);
      viewUpdated();
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Override this function so that it doesn't threshold the image twice
 */
@Override public void processImage(int sourceID,long frameID,final BufferedImage buffered,ImageBase input){
  System.out.flush();
  original=ConvertBufferedImage.checkCopy(buffered,original);
  work=ConvertBufferedImage.checkDeclare(buffered,work);
  final double timeInSeconds;
synchronized (this) {
    long before=System.nanoTime();
    detector.process((T)input);
    long after=System.nanoTime();
    timeInSeconds=(after - before) * 1e-9;
  }
synchronized (detected) {
    this.detected.reset();
    for (    QrCode d : detector.getDetections()) {
      this.detected.grow().set(d);
    }
    this.failures.reset();
    for (    QrCode d : detector.getFailures()) {
      this.failures.grow().set(d);
    }
    System.out.println("String_Node_Str" + failures.size());
    for (    QrCode qr : failures.toList()) {
      System.out.println("String_Node_Str" + qr.failureCause);
    }
  }
  SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      controls.setProcessingTime(timeInSeconds);
      viewUpdated();
    }
  }
);
}
Program: 150612
Project: 150612
Buggy source:
@Override public void process(T gray){
  long time0=System.nanoTime();
  binary.reshape(gray.width,gray.height);
  inputToBinary.process(gray,binary);
  long time1=System.nanoTime();
  milliBinary.update((time1 - time0) * 1e-6);
  System.out.printf("String_Node_Str",milliBinary.getAverage());
  detectPositionPatterns.process(gray,binary);
  time0=System.nanoTime();
  decoder.process(detectPositionPatterns.getPositionPatterns(),gray);
  time1=System.nanoTime();
  milliDecoding.update((time1 - time0) * 1e-6);
  System.out.printf("String_Node_Str",milliDecoding.getAverage());
  System.out.println("String_Node_Str" + decoder.getFailures().size());
  for (  QrCode qr : decoder.getFailures()) {
    System.out.println("String_Node_Str" + qr.failureCause);
  }
}

Fixed version (ground truth):
@Override public void process(T gray){
  long time0=System.nanoTime();
  binary.reshape(gray.width,gray.height);
  inputToBinary.process(gray,binary);
  long time1=System.nanoTime();
  milliBinary.update((time1 - time0) * 1e-6);
  System.out.printf("String_Node_Str",milliBinary.getAverage());
  detectPositionPatterns.process(gray,binary);
  time0=System.nanoTime();
  decoder.process(detectPositionPatterns.getPositionPatterns(),gray);
  time1=System.nanoTime();
  milliDecoding.update((time1 - time0) * 1e-6);
  System.out.printf("String_Node_Str",milliDecoding.getAverage());
}
Program: 150613
Project: 150613
Buggy source:
public void reset(){
  for (int i=0; i < 4; i++) {
    ppCorner.get(i).set(0,0);
    ppDown.get(i).set(0,0);
    ppRight.get(i).set(0,0);
  }
  version=1;
  error=L;
  mask=QrCodeMaskPattern.M111;
  alignment.reset();
  mode=Mode.ALPHANUMERIC;
  failureCause=Failure.NONE;
  rawbits=null;
  rawdata=null;
  message=null;
}

Fixed version (ground truth):
/** 
 * Resets the QR-Code so that it's in its initial state.
 */
public void reset(){
  for (int i=0; i < 4; i++) {
    ppCorner.get(i).set(0,0);
    ppDown.get(i).set(0,0);
    ppRight.get(i).set(0,0);
  }
  this.threshCorner=0;
  this.threshDown=0;
  this.threshRight=0;
  version=1;
  error=L;
  mask=QrCodeMaskPattern.M111;
  alignment.reset();
  mode=Mode.ALPHANUMERIC;
  failureCause=Failure.NONE;
  rawbits=null;
  rawdata=null;
  message=null;
}
Program: 150614
Project: 150614
Buggy source:
/** 
 * Increases the size of the data array so that it can store an addition number of bits
 * @param amountBits Number of bits beyond 'size' that you wish the array to be able to store
 * @param saveValue if true it will save the value of the array. If false it will not copy it
 */
public void growArray(int amountBits,boolean saveValue){
  size=size + amountBits;
  int N=size / 8 + (size % 8 == 0 ? 0 : 1);
  if (N > data.length) {
    byte[] tmp=new byte[N];
    if (saveValue)     System.arraycopy(data,0,tmp,0,data.length);
    this.data=tmp;
  }
}

Fixed version (ground truth):
/** 
 * Increases the size of the data array so that it can store an addition number of bits
 * @param amountBits Number of bits beyond 'size' that you wish the array to be able to store
 * @param saveValue if true it will save the value of the array. If false it will not copy it
 */
public void growArray(int amountBits,boolean saveValue){
  size=size + amountBits;
  int N=size / 8 + (size % 8 == 0 ? 0 : 1);
  if (N > data.length) {
    int extra=Math.min(1024,N + 10);
    byte[] tmp=new byte[N + extra];
    if (saveValue)     System.arraycopy(data,0,tmp,0,data.length);
    this.data=tmp;
  }
}
Program: 150615
Project: 150615
Buggy source:
public static Mode lookup(int bits){
  if (NUMERIC.bits == bits)   return NUMERIC;
 else   if (ALPHANUMERIC.bits == bits)   return ALPHANUMERIC;
 else   if (BYTE.bits == bits)   return BYTE;
 else   if (KANJI.bits == bits)   return KANJI;
 else   if (ECI.bits == bits)   return ECI;
 else   if (FNC1_FIRST.bits == bits)   return FNC1_FIRST;
 else   if (FNC1_SECOND.bits == bits)   return FNC1_SECOND;
 else   return UNKNOWN;
}

Fixed version (ground truth):
public static Mode lookup(int bits){
  if (NUMERIC.bits == bits)   return NUMERIC;
 else   if (ALPHANUMERIC.bits == bits)   return ALPHANUMERIC;
 else   if (BYTE.bits == bits)   return BYTE;
 else   if (KANJI.bits == bits)   return KANJI;
 else   if (ECI.bits == bits)   return ECI;
 else   if (STRUCTURE_APPENDED.bits == bits)   return STRUCTURE_APPENDED;
 else   if (FNC1_FIRST.bits == bits)   return FNC1_FIRST;
 else   if (FNC1_SECOND.bits == bits)   return FNC1_SECOND;
 else   return UNKNOWN;
}
Program: 150616
Project: 150616
Buggy source:
/** 
 * Creates a list of alignment patterns to look for and their grid coordinates
 */
void initializePatterns(QrCode qr){
  int qrsize=qr.getNumberOfModules();
  int where[]=QrCode.VERSION_INFO[qr.version].alignment;
  qr.alignment.reset();
  lookup.reset();
  for (int row=0; row < where.length; row++) {
    for (int col=0; col < where.length; col++) {
      boolean skip=false;
      if (row == 0 && col == 0)       skip=true;
 else       if (row == 0 && col == where.length - 1)       skip=true;
 else       if (row == where.length - 1 && col == 0)       skip=true;
      if (skip) {
        lookup.add(null);
      }
 else {
        QrCode.Alignment a=qr.alignment.grow();
        a.moduleX=where[col];
        a.moduleY=where[row];
        lookup.add(a);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Creates a list of alignment patterns to look for and their grid coordinates
 */
void initializePatterns(QrCode qr){
  int N=qr.getNumberOfModules();
  int where[]=QrCode.VERSION_INFO[qr.version].alignment;
  qr.alignment.reset();
  lookup.reset();
  for (int row=where.length - 1; row >= 0; row--) {
    for (int col=0; col < where.length; col++) {
      boolean skip=false;
      if (row == 0 && col == 0)       skip=true;
 else       if (row == where.length - 1 && col == where.length - 1)       skip=true;
 else       if (row == where.length - 1 && col == 0)       skip=true;
      if (skip) {
        lookup.add(null);
      }
 else {
        QrCode.Alignment a=qr.alignment.grow();
        a.moduleX=where[col];
        a.moduleY=N - where[row] - 1;
        lookup.add(a);
      }
    }
  }
}
Program: 150617
Project: 150617
Buggy source:
private int decodeVersion(){
  int bits=this.bits.data[0];
  int message;
  if (QrCodePolynomialMath.checkVersionBits(bits)) {
    message=bits >> 12;
  }
 else {
    message=QrCodePolynomialMath.correctVersionBits(bits);
  }
  if (message > QrCode.MAX_VERSION || message < QrCode.VERSION_VERSION)   return -1;
  return message;
}

Fixed version (ground truth):
/** 
 * Decode version information from read in bits
 * @return The found version or -1 if it failed
 */
private int decodeVersion(){
  int bits=this.bits.data[0];
  int message;
  if (QrCodePolynomialMath.checkVersionBits(bits)) {
    message=bits >> 12;
  }
 else {
    message=QrCodePolynomialMath.correctVersionBits(bits);
  }
  if (message > QrCode.MAX_VERSION || message < QrCode.VERSION_VERSION)   return -1;
  return message;
}
Program: 150618
Project: 150618
Buggy source:
private static int alignToBytes(int lengthBits){
  return lengthBits + (8 - lengthBits % 8) % 8;
}

Fixed version (ground truth):
public static int alignToBytes(int lengthBits){
  return lengthBits + (8 - lengthBits % 8) % 8;
}
Program: 150619
Project: 150619
Buggy source:
/** 
 * Creates a QR-Code which encodes data in the alphanumeric format
 * @param alphaNumeric String containing only alphanumeric values.
 * @return The QR-Code
 */
public QrCode alphanumeric(String alphaNumeric){
}

Fixed version (ground truth):
/** 
 * Creates a QR-Code which encodes data in the alphanumeric format
 * @param alphaNumeric String containing only alphanumeric values.
 * @return The QR-Code
 */
public QrCodeEncoder alphanumeric(String alphaNumeric){
}
Program: 150620
Project: 150620
Buggy source:
/** 
 * Creates a QR-Code which encodes Kanji characters
 * @param message Data to be encoded
 * @return The QR-Code
 */
public QrCode kanji(String message){
}

Fixed version (ground truth):
/** 
 * Creates a QR-Code which encodes Kanji characters
 * @param message Data to be encoded
 * @return The QR-Code
 */
public QrCodeEncoder kanji(String message){
}
Program: 150621
Project: 150621
Buggy source:
/** 
 * Creates a QR-Code which encodes a number sequence
 * @param numbers Array of numbers. Each number has to be from 0 to 9 inclusive.
 * @return The QR-Code
 */
public QrCode numeric(int[] numbers){
}

Fixed version (ground truth):
/** 
 * Creates a QR-Code which encodes a number sequence
 * @param numbers Array of numbers. Each number has to be from 0 to 9 inclusive.
 * @return The QR-Code
 */
public QrCodeEncoder numeric(int[] numbers){
}
Program: 150622
Project: 150622
Buggy source:
public static byte[] alphanumericToValues(String data){
  byte[] output=new byte[data.length()];
  for (int i=0; i < data.length(); i++) {
    char c=data.charAt(i);
    if (Character.isDigit(c)) {
      output[i]=(byte)(c - '0');
    }
 else {
      int value=(int)(Character.toUpperCase(c) - 'A');
      if (value >= 0 && value < 36) {
        output[i]=(byte)(10 + value);
      }
 else {
switch (c) {
case ' ':
          output[i]=36;
        break;
case '$':
      output[i]=37;
    break;
case '%':
  output[i]=38;
break;
case '*':
output[i]=39;
break;
case '+':
output[i]=40;
break;
case '-':
output[i]=41;
break;
case '.':
output[i]=42;
break;
case '/':
output[i]=43;
break;
case ':':
output[i]=44;
break;
default :
throw new IllegalArgumentException("String_Node_Str" + c + "String_Node_Str"+ (int)c);
}
}
}
}
return output;
}

Fixed version (ground truth):
public static byte[] alphanumericToValues(String data){
  byte[] output=new byte[data.length()];
  for (int i=0; i < data.length(); i++) {
    char c=data.charAt(i);
    int value=ALPHANUMERIC.indexOf(c);
    if (value < 0)     throw new IllegalArgumentException("String_Node_Str" + c + "String_Node_Str"+ (int)c);
    output[i]=(byte)value;
  }
  return output;
}
Program: 150623
Project: 150623
Buggy source:
public QrCodeEncoder(){
  qr.version=-1;
}

Fixed version (ground truth):
public QrCodeEncoder(){
  reset();
}
Program: 150624
Project: 150624
Buggy source:
/** 
 * Creates a QR-Code which encodes data in the byte format.
 * @param data Data to be encoded
 * @return The QR-Code
 */
public QrCode bytes(byte[] data){
}

Fixed version (ground truth):
/** 
 * Creates a QR-Code which encodes data in the byte format.
 * @param data Data to be encoded
 * @return The QR-Code
 */
public QrCodeEncoder bytes(byte[] data){
}
Program: 150625
Project: 150625
Buggy source:
public static char valueToAlphanumeric(int value){
  if (value <= 9)   return (char)(value + '0');
  if (value < 36)   return (char)(value - 10 + 'A');
switch (value) {
case 36:
    return ' ';
case 37:
  return '$';
case 38:
return '%';
case 39:
return '*';
case 40:
return '+';
case 41:
return '-';
case 42:
return '.';
case 43:
return '/';
case 44:
return ':';
default :
throw new IllegalArgumentException("String_Node_Str");
}
}

Fixed version (ground truth):
public static char valueToAlphanumeric(int value){
  if (value < 0 || value >= ALPHANUMERIC.length())   throw new RuntimeException("String_Node_Str");
  return ALPHANUMERIC.charAt(value);
}
Program: 150626
Project: 150626
Buggy source:
@Before public void setup(){
  expected=new QrCodeEncoder().setVersion(2).setError(QrCode.ErrorLevel.H).setMask(QrCodeMaskPattern.M010).numeric(message);
}

Fixed version (ground truth):
@Before public void setup(){
  expected=new QrCodeEncoder().setVersion(2).setError(QrCode.ErrorLevel.H).setMask(QrCodeMaskPattern.M010).numeric(message).fixate();
}
Program: 150628
Project: 150628
Buggy source:
@Override public void viewUpdated(){
  BufferedImage active=null;
  if (controls.selectedView == 0) {
    active=original;
  }
 else   if (controls.selectedView == 1) {
    VisualizeBinaryData.renderBinary(detector.getBinary(),false,work);
    active=work;
    work.setRGB(0,0,work.getRGB(0,0));
  }
 else {
    Graphics2D g2=work.createGraphics();
    g2.setColor(Color.BLACK);
    g2.fillRect(0,0,work.getWidth(),work.getHeight());
    active=work;
  }
  guiImage.setBufferedImage(active);
  guiImage.setScale(controls.zoom);
  guiImage.repaint();
}

Fixed version (ground truth):
@Override public void viewUpdated(){
  BufferedImage active;
  if (controls.selectedView == 0) {
    active=original;
  }
 else   if (controls.selectedView == 1) {
    VisualizeBinaryData.renderBinary(detector.getBinary(),false,work);
    active=work;
    work.setRGB(0,0,work.getRGB(0,0));
  }
 else {
    Graphics2D g2=work.createGraphics();
    g2.setColor(Color.BLACK);
    g2.fillRect(0,0,work.getWidth(),work.getHeight());
    active=work;
  }
  guiImage.setBufferedImage(active);
  guiImage.setScale(controls.zoom);
  guiImage.repaint();
}
Program: 150629
Project: 150629
Buggy source:
private void renderBinaryValues(Graphics2D g2,QrCode qr){
  QrCodeAlignmentPatternLocator<T> locator=detector.getDecoder().getAlignmentLocator();
  locator.setTransform(qr);
  List<Point2D_I32> points=QrCode.LOCATION_BITS[qr.version];
  PackedBits8 bits=new PackedBits8();
  bits.data=qr.rawbits;
  bits.size=qr.rawbits.length * 8;
  Point2D_F32 p=new Point2D_F32();
  for (int i=0; i < bits.size; i++) {
    Point2D_I32 c=points.get(i);
    locator.gridToImage(c.y + 0.5f,c.x + 0.5f,p);
    int value=qr.mask.apply(c.y,c.x,bits.get(i));
    if (value == 1)     g2.setColor(Color.BLACK);
 else     if (value == 0)     g2.setColor(Color.WHITE);
 else     g2.setColor(Color.RED);
    renderCircleAt(g2,p);
  }
  int N=qr.totalModules();
  g2.setColor(Color.BLUE);
  locator.gridToImage(0,N - 7,p);
  renderCircleAt(g2,p);
  locator.gridToImage(7,N - 7,p);
  renderCircleAt(g2,p);
  locator.gridToImage(N - 7,0,p);
  renderCircleAt(g2,p);
  locator.gridToImage(N - 7,7,p);
  renderCircleAt(g2,p);
}

Fixed version (ground truth):
/** 
 * Draws the estimated value of each bit onto the image
 */
private void renderBinaryValues(Graphics2D g2,QrCode qr){
  locator.setTransform(qr);
  List<Point2D_I32> points=QrCode.LOCATION_BITS[qr.version];
  PackedBits8 bits=new PackedBits8();
  bits.data=qr.rawbits;
  bits.size=qr.rawbits.length * 8;
  Point2D_F32 p=new Point2D_F32();
  for (int i=0; i < bits.size; i++) {
    Point2D_I32 c=points.get(i);
    locator.gridToImage(c.y + 0.5f,c.x + 0.5f,p);
    int value=qr.mask.apply(c.y,c.x,bits.get(i));
    if (value == 1)     g2.setColor(Color.BLACK);
 else     if (value == 0)     g2.setColor(Color.WHITE);
 else     g2.setColor(Color.RED);
    renderCircleAt(g2,p);
  }
}
Program: 150630
Project: 150630
Buggy source:
public ErrorBlock(int codewords,int dataCodewords,int eccBlocks){
  this.codewords=codewords;
  this.dataCodewords=dataCodewords;
  this.eccBlocks=eccBlocks;
}

Fixed version (ground truth):
public ErrorBlock(int codewords,int dataCodewords,int blocks){
  this.codewords=codewords;
  this.dataCodewords=dataCodewords;
  this.blocks=blocks;
}
Program: 150631
Project: 150631
Buggy source:
/** 
 * Reconstruct the data while applying error correction.
 */
private boolean applyErrorCorrection(QrCode qr){
  QrCode.VersionInfo info=QrCode.VERSION_INFO[qr.version];
  QrCode.ErrorBlock block=info.levels.get(qr.error);
  int wordsBlockAllA=block.codewords;
  int wordsBlockDataA=block.dataCodewords;
  int wordsEcc=wordsBlockAllA - wordsBlockDataA;
  int numBlocksA=block.eccBlocks;
  int wordsBlockAllB=wordsBlockAllA + 1;
  int wordsBlockDataB=wordsBlockDataA + 1;
  int numBlocksB=(info.codewords - wordsBlockAllA * numBlocksA) / wordsBlockAllB;
  int totalBlocks=numBlocksA + numBlocksB;
  int totalDataBytes=wordsBlockDataA * numBlocksA + wordsBlockDataB * numBlocksB;
  qr.rawdata=new byte[totalDataBytes];
  ecc.resize(wordsEcc);
  rscodes.generator(wordsEcc);
  if (!decodeBlocks(qr,wordsBlockDataA,numBlocksA,0,0,totalDataBytes,totalBlocks))   return false;
  return decodeBlocks(qr,wordsBlockDataB,numBlocksB,numBlocksA * wordsBlockDataA,numBlocksA,totalDataBytes,totalBlocks);
}

Fixed version (ground truth):
/** 
 * Reconstruct the data while applying error correction.
 */
private boolean applyErrorCorrection(QrCode qr){
  QrCode.VersionInfo info=QrCode.VERSION_INFO[qr.version];
  QrCode.ErrorBlock block=info.levels.get(qr.error);
  int wordsBlockAllA=block.codewords;
  int wordsBlockDataA=block.dataCodewords;
  int wordsEcc=wordsBlockAllA - wordsBlockDataA;
  int numBlocksA=block.blocks;
  int wordsBlockAllB=wordsBlockAllA + 1;
  int wordsBlockDataB=wordsBlockDataA + 1;
  int numBlocksB=(info.codewords - wordsBlockAllA * numBlocksA) / wordsBlockAllB;
  int totalBlocks=numBlocksA + numBlocksB;
  int totalDataBytes=wordsBlockDataA * numBlocksA + wordsBlockDataB * numBlocksB;
  qr.rawdata=new byte[totalDataBytes];
  ecc.resize(wordsEcc);
  rscodes.generator(wordsEcc);
  if (!decodeBlocks(qr,wordsBlockDataA,numBlocksA,0,0,totalDataBytes,totalBlocks))   return false;
  return decodeBlocks(qr,wordsBlockDataB,numBlocksB,numBlocksA * wordsBlockDataA,numBlocksA,totalDataBytes,totalBlocks);
}