nus-yam/ex-repair huggingface dataset:
Program: 24175
Project: 24175
Buggy source:
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}

Fixed version (ground truth):
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}
Program: 24176
Project: 24176
Buggy source:
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,gesture,entryName));
  mChanged=true;
}

Fixed version (ground truth):
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,entryName));
  mChanged=true;
}
Program: 24177
Project: 24177
Buggy source:
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}

Fixed version (ground truth):
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,mOrientationStyle,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}
Program: 24178
Project: 24178
Buggy source:
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  final Matrix matrix=new Matrix();
  matrix.setTranslate(-rect.left,-rect.top);
  matrix.postScale(width / rect.width(),height / rect.height());
  matrix.mapPoints(pts);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}

Fixed version (ground truth):
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  GestureUtilities.translate(pts,-rect.left,-rect.top);
  float sx=width / rect.width();
  float sy=height / rect.height();
  float scale=sx > sy ? sy : sx;
  GestureUtilities.scale(pts,scale,scale);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}
Program: 24179
Project: 24179
Buggy source:
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  Matrix tr=new Matrix();
  tr.setTranslate(-centroid[0],-centroid[1]);
  tr.mapPoints(points);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=-90;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    angle=(float)(180 * angle / Math.PI);
    Matrix trans=new Matrix();
    trans.setRotate(-angle);
    trans.mapPoints(points);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}

Fixed version (ground truth):
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  translate(points,-centroid[0],-centroid[1]);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=(float)-Math.PI / 2;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    rotate(points,-angle);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}
Program: 24180
Project: 24180
Buggy source:
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int samplingType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (samplingType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(samplingType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int sequenceType,int orientationType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (sequenceType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(orientationType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}
Program: 24181
Project: 24181
Buggy source:
private static float[] temporalSampler(int samplingType,Gesture gesture){
  float[] pts=GestureUtilities.temporalSampling(gesture.getStrokes().get(0),SEQUENCE_SAMPLE_SIZE);
  float[] center=GestureUtilities.computeCentroid(pts);
  float orientation=(float)Math.atan2(pts[1] - center[1],pts[0] - center[0]);
  orientation*=180 / Math.PI;
  float adjustment=-orientation;
  if (samplingType == GestureLibrary.ORIENTATION_SENSITIVE) {
    int count=ORIENTATIONS.length;
    for (int i=0; i < count; i++) {
      float delta=ORIENTATIONS[i] - orientation;
      if (Math.abs(delta) < Math.abs(adjustment)) {
        adjustment=delta;
      }
    }
  }
  Matrix m=new Matrix();
  m.setTranslate(-center[0],-center[1]);
  m.postRotate(adjustment);
  m.mapPoints(pts);
  return pts;
}

Fixed version (ground truth):
private static float[] temporalSampler(int orientationType,Gesture gesture){
  float[] pts=GestureUtilities.temporalSampling(gesture.getStrokes().get(0),SEQUENCE_SAMPLE_SIZE);
  float[] center=GestureUtilities.computeCentroid(pts);
  float orientation=(float)Math.atan2(pts[1] - center[1],pts[0] - center[0]);
  float adjustment=-orientation;
  if (orientationType == GestureLibrary.ORIENTATION_SENSITIVE) {
    int count=ORIENTATIONS.length;
    for (int i=0; i < count; i++) {
      float delta=ORIENTATIONS[i] - orientation;
      if (Math.abs(delta) < Math.abs(adjustment)) {
        adjustment=delta;
      }
    }
  }
  GestureUtilities.translate(pts,-center[0],-center[1]);
  GestureUtilities.rotate(pts,adjustment);
  return pts;
}
Program: 24183
Project: 24183
Buggy source:
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}

Fixed version (ground truth):
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}
Program: 24184
Project: 24184
Buggy source:
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,gesture,entryName));
  mChanged=true;
}

Fixed version (ground truth):
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,entryName));
  mChanged=true;
}
Program: 24185
Project: 24185
Buggy source:
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}

Fixed version (ground truth):
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,mOrientationStyle,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}
Program: 24186
Project: 24186
Buggy source:
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  final Matrix matrix=new Matrix();
  matrix.setTranslate(-rect.left,-rect.top);
  matrix.postScale(width / rect.width(),height / rect.height());
  matrix.mapPoints(pts);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}

Fixed version (ground truth):
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  GestureUtilities.translate(pts,-rect.left,-rect.top);
  float sx=width / rect.width();
  float sy=height / rect.height();
  float scale=sx > sy ? sy : sx;
  GestureUtilities.scale(pts,scale,scale);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}
Program: 24187
Project: 24187
Buggy source:
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  Matrix tr=new Matrix();
  tr.setTranslate(-centroid[0],-centroid[1]);
  tr.mapPoints(points);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=-90;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    angle=(float)(180 * angle / Math.PI);
    Matrix trans=new Matrix();
    trans.setRotate(-angle);
    trans.mapPoints(points);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}

Fixed version (ground truth):
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  translate(points,-centroid[0],-centroid[1]);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=(float)-Math.PI / 2;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    rotate(points,-angle);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}
Program: 24188
Project: 24188
Buggy source:
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int samplingType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (samplingType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(samplingType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int sequenceType,int orientationType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (sequenceType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(orientationType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}
Program: 24189
Project: 24189
Buggy source:
private static float[] temporalSampler(int samplingType,Gesture gesture){
  float[] pts=GestureUtilities.temporalSampling(gesture.getStrokes().get(0),SEQUENCE_SAMPLE_SIZE);
  float[] center=GestureUtilities.computeCentroid(pts);
  float orientation=(float)Math.atan2(pts[1] - center[1],pts[0] - center[0]);
  orientation*=180 / Math.PI;
  float adjustment=-orientation;
  if (samplingType == GestureLibrary.ORIENTATION_SENSITIVE) {
    int count=ORIENTATIONS.length;
    for (int i=0; i < count; i++) {
      float delta=ORIENTATIONS[i] - orientation;
      if (Math.abs(delta) < Math.abs(adjustment)) {
        adjustment=delta;
      }
    }
  }
  Matrix m=new Matrix();
  m.setTranslate(-center[0],-center[1]);
  m.postRotate(adjustment);
  m.mapPoints(pts);
  return pts;
}

Fixed version (ground truth):
private static float[] temporalSampler(int orientationType,Gesture gesture){
  float[] pts=GestureUtilities.temporalSampling(gesture.getStrokes().get(0),SEQUENCE_SAMPLE_SIZE);
  float[] center=GestureUtilities.computeCentroid(pts);
  float orientation=(float)Math.atan2(pts[1] - center[1],pts[0] - center[0]);
  float adjustment=-orientation;
  if (orientationType == GestureLibrary.ORIENTATION_SENSITIVE) {
    int count=ORIENTATIONS.length;
    for (int i=0; i < count; i++) {
      float delta=ORIENTATIONS[i] - orientation;
      if (Math.abs(delta) < Math.abs(adjustment)) {
        adjustment=delta;
      }
    }
  }
  GestureUtilities.translate(pts,-center[0],-center[1]);
  GestureUtilities.rotate(pts,adjustment);
  return pts;
}
Program: 24191
Project: 24191
Buggy source:
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}

Fixed version (ground truth):
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}
Program: 24192
Project: 24192
Buggy source:
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,gesture,entryName));
  mChanged=true;
}

Fixed version (ground truth):
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,entryName));
  mChanged=true;
}
Program: 24193
Project: 24193
Buggy source:
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}

Fixed version (ground truth):
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,mOrientationStyle,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}
Program: 24194
Project: 24194
Buggy source:
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  final Matrix matrix=new Matrix();
  matrix.setTranslate(-rect.left,-rect.top);
  matrix.postScale(width / rect.width(),height / rect.height());
  matrix.mapPoints(pts);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}

Fixed version (ground truth):
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  GestureUtilities.translate(pts,-rect.left,-rect.top);
  float sx=width / rect.width();
  float sy=height / rect.height();
  float scale=sx > sy ? sy : sx;
  GestureUtilities.scale(pts,scale,scale);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}
Program: 24195
Project: 24195
Buggy source:
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  Matrix tr=new Matrix();
  tr.setTranslate(-centroid[0],-centroid[1]);
  tr.mapPoints(points);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=-90;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    angle=(float)(180 * angle / Math.PI);
    Matrix trans=new Matrix();
    trans.setRotate(-angle);
    trans.mapPoints(points);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}

Fixed version (ground truth):
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  translate(points,-centroid[0],-centroid[1]);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=(float)-Math.PI / 2;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    rotate(points,-angle);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}
Program: 24196
Project: 24196
Buggy source:
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int samplingType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (samplingType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(samplingType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int sequenceType,int orientationType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (sequenceType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(orientationType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}
Program: 24197
Project: 24197
Buggy source:
private static float[] temporalSampler(int samplingType,Gesture gesture){
  float[] pts=GestureUtilities.temporalSampling(gesture.getStrokes().get(0),SEQUENCE_SAMPLE_SIZE);
  float[] center=GestureUtilities.computeCentroid(pts);
  float orientation=(float)Math.atan2(pts[1] - center[1],pts[0] - center[0]);
  orientation*=180 / Math.PI;
  float adjustment=-orientation;
  if (samplingType == GestureLibrary.ORIENTATION_SENSITIVE) {
    int count=ORIENTATIONS.length;
    for (int i=0; i < count; i++) {
      float delta=ORIENTATIONS[i] - orientation;
      if (Math.abs(delta) < Math.abs(adjustment)) {
        adjustment=delta;
      }
    }
  }
  Matrix m=new Matrix();
  m.setTranslate(-center[0],-center[1]);
  m.postRotate(adjustment);
  m.mapPoints(pts);
  return pts;
}

Fixed version (ground truth):
private static float[] temporalSampler(int orientationType,Gesture gesture){
  float[] pts=GestureUtilities.temporalSampling(gesture.getStrokes().get(0),SEQUENCE_SAMPLE_SIZE);
  float[] center=GestureUtilities.computeCentroid(pts);
  float orientation=(float)Math.atan2(pts[1] - center[1],pts[0] - center[0]);
  float adjustment=-orientation;
  if (orientationType == GestureLibrary.ORIENTATION_SENSITIVE) {
    int count=ORIENTATIONS.length;
    for (int i=0; i < count; i++) {
      float delta=ORIENTATIONS[i] - orientation;
      if (Math.abs(delta) < Math.abs(adjustment)) {
        adjustment=delta;
      }
    }
  }
  GestureUtilities.translate(pts,-center[0],-center[1]);
  GestureUtilities.rotate(pts,adjustment);
  return pts;
}
Program: 24199
Project: 24199
Buggy source:
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}

Fixed version (ground truth):
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}
Program: 24200
Project: 24200
Buggy source:
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,entryName));
  mChanged=true;
}

Fixed version (ground truth):
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,gesture,entryName));
  mChanged=true;
}
Program: 24201
Project: 24201
Buggy source:
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,mOrientationStyle,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}

Fixed version (ground truth):
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}
Program: 24202
Project: 24202
Buggy source:
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  GestureUtilities.translate(pts,-rect.left,-rect.top);
  float sx=width / rect.width();
  float sy=height / rect.height();
  float scale=sx > sy ? sy : sx;
  GestureUtilities.scale(pts,scale,scale);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}

Fixed version (ground truth):
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  final Matrix matrix=new Matrix();
  matrix.setTranslate(-rect.left,-rect.top);
  matrix.postScale(width / rect.width(),height / rect.height());
  matrix.mapPoints(pts);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}
Program: 24203
Project: 24203
Buggy source:
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  translate(points,-centroid[0],-centroid[1]);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=(float)-Math.PI / 2;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    rotate(points,-angle);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}

Fixed version (ground truth):
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  Matrix tr=new Matrix();
  tr.setTranslate(-centroid[0],-centroid[1]);
  tr.mapPoints(points);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=-90;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    angle=(float)(180 * angle / Math.PI);
    Matrix trans=new Matrix();
    trans.setRotate(-angle);
    trans.mapPoints(points);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}
Program: 24204
Project: 24204
Buggy source:
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int sequenceType,int orientationType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (sequenceType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(orientationType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int samplingType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (samplingType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(samplingType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}
Program: 24205
Project: 24205
Buggy source:
private static float[] temporalSampler(int orientationType,Gesture gesture){
  float[] pts=GestureUtilities.temporalSampling(gesture.getStrokes().get(0),SEQUENCE_SAMPLE_SIZE);
  float[] center=GestureUtilities.computeCentroid(pts);
  float orientation=(float)Math.atan2(pts[1] - center[1],pts[0] - center[0]);
  float adjustment=-orientation;
  if (orientationType == GestureLibrary.ORIENTATION_SENSITIVE) {
    int count=ORIENTATIONS.length;
    for (int i=0; i < count; i++) {
      float delta=ORIENTATIONS[i] - orientation;
      if (Math.abs(delta) < Math.abs(adjustment)) {
        adjustment=delta;
      }
    }
  }
  GestureUtilities.translate(pts,-center[0],-center[1]);
  GestureUtilities.rotate(pts,adjustment);
  return pts;
}

Fixed version (ground truth):
private static float[] temporalSampler(int samplingType,Gesture gesture){
  float[] pts=GestureUtilities.temporalSampling(gesture.getStrokes().get(0),SEQUENCE_SAMPLE_SIZE);
  float[] center=GestureUtilities.computeCentroid(pts);
  float orientation=(float)Math.atan2(pts[1] - center[1],pts[0] - center[0]);
  orientation*=180 / Math.PI;
  float adjustment=-orientation;
  if (samplingType == GestureLibrary.ORIENTATION_SENSITIVE) {
    int count=ORIENTATIONS.length;
    for (int i=0; i < count; i++) {
      float delta=ORIENTATIONS[i] - orientation;
      if (Math.abs(delta) < Math.abs(adjustment)) {
        adjustment=delta;
      }
    }
  }
  Matrix m=new Matrix();
  m.setTranslate(-center[0],-center[1]);
  m.postRotate(adjustment);
  m.mapPoints(pts);
  return pts;
}
Program: 24207
Project: 24207
Buggy source:
private void getPermissionsForPackage(String packageName,Set<PermissionInfo> permSet){
  PackageInfo pkgInfo;
  try {
    pkgInfo=mPm.getPackageInfo(packageName,PackageManager.GET_PERMISSIONS);
  }
 catch (  NameNotFoundException e) {
    Log.w(TAG,"String_Node_Str" + packageName);
    return;
  }
  if (pkgInfo == null) {
    return;
  }
  String strList[]=pkgInfo.requestedPermissions;
  if (strList == null) {
    return;
  }
  extractPerms(strList,permSet);
}

Fixed version (ground truth):
private void getPermissionsForPackage(String packageName,Set<PermissionInfo> permSet){
  PackageInfo pkgInfo;
  try {
    pkgInfo=mPm.getPackageInfo(packageName,PackageManager.GET_PERMISSIONS);
  }
 catch (  NameNotFoundException e) {
    Log.w(TAG,"String_Node_Str" + packageName);
    return;
  }
  if ((pkgInfo != null) && (pkgInfo.requestedPermissions != null)) {
    extractPerms(pkgInfo.requestedPermissions,permSet);
  }
}
Program: 24208
Project: 24208
Buggy source:
public AppSecurityPermissions(Context context,PackageParser.Package pkg){
  mContext=context;
  mPm=mContext.getPackageManager();
  mPermsList=new ArrayList<PermissionInfo>();
  Set<PermissionInfo> permSet=new HashSet<PermissionInfo>();
  if (pkg == null) {
    return;
  }
  if (pkg.mSharedUserId != null) {
    int sharedUid;
    try {
      sharedUid=mPm.getUidForSharedUser(pkg.mSharedUserId);
    }
 catch (    NameNotFoundException e) {
      Log.w(TAG,"String_Node_Str" + pkg.packageName);
      return;
    }
    getAllUsedPermissions(sharedUid,permSet);
  }
 else {
    ArrayList<String> strList=pkg.requestedPermissions;
    int size;
    if ((strList == null) || ((size=strList.size()) == 0)) {
      return;
    }
    extractPerms(strList.toArray(new String[size]),permSet);
  }
  for (  PermissionInfo tmpInfo : permSet) {
    mPermsList.add(tmpInfo);
  }
}

Fixed version (ground truth):
public AppSecurityPermissions(Context context,PackageParser.Package pkg){
  mContext=context;
  mPm=mContext.getPackageManager();
  mPermsList=new ArrayList<PermissionInfo>();
  Set<PermissionInfo> permSet=new HashSet<PermissionInfo>();
  if (pkg == null) {
    return;
  }
  if (pkg.requestedPermissions != null) {
    ArrayList<String> strList=pkg.requestedPermissions;
    int size=strList.size();
    if (size > 0) {
      extractPerms(strList.toArray(new String[size]),permSet);
    }
  }
  if (pkg.mSharedUserId != null) {
    int sharedUid;
    try {
      sharedUid=mPm.getUidForSharedUser(pkg.mSharedUserId);
      getAllUsedPermissions(sharedUid,permSet);
    }
 catch (    NameNotFoundException e) {
      Log.w(TAG,"String_Node_Str" + pkg.packageName);
    }
  }
  for (  PermissionInfo tmpInfo : permSet) {
    mPermsList.add(tmpInfo);
  }
}
Program: 24209
Project: 24209
Buggy source:
/** 
 * Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.
 * @param parcel The parcel to copy this bundle to.
 */
public void writeToParcel(Parcel parcel,int flags){
  parcel.writeBundle(this);
}

Fixed version (ground truth):
/** 
 * Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.
 * @param parcel The parcel to copy this bundle to.
 */
public void writeToParcel(Parcel parcel,int flags){
  if (mParcelledData != null) {
    int length=mParcelledData.dataSize();
    parcel.writeInt(length);
    parcel.writeInt(0x4C444E42);
    parcel.appendFrom(mParcelledData,0,length);
  }
 else {
    parcel.writeInt(-1);
    parcel.writeInt(0x4C444E42);
    int oldPos=parcel.dataPosition();
    parcel.writeMapInternal(mMap);
    int newPos=parcel.dataPosition();
    parcel.setDataPosition(oldPos - 8);
    int length=newPos - oldPos;
    parcel.writeInt(length);
    parcel.setDataPosition(newPos);
  }
}
Program: 24210
Project: 24210
Buggy source:
/** 
 * If the underlying data are stored as a Parcel, unparcel them using the currently assigned class loader.
 */
synchronized void unparcel(){
  if (mParcelledData == null) {
    return;
  }
  mParcelledData.setDataPosition(0);
  Bundle b=mParcelledData.readBundleUnpacked(mClassLoader);
  mMap=b.mMap;
  mHasFds=mParcelledData.hasFileDescriptors();
  mFdsKnown=true;
  mParcelledData.recycle();
  mParcelledData=null;
}

Fixed version (ground truth):
/** 
 * If the underlying data are stored as a Parcel, unparcel them using the currently assigned class loader.
 */
synchronized void unparcel(){
  if (mParcelledData == null) {
    return;
  }
  int N=mParcelledData.readInt();
  if (N < 0) {
    return;
  }
  if (mMap == null) {
    mMap=new HashMap<String,Object>();
  }
  mParcelledData.readMapInternal(mMap,N,mClassLoader);
  mParcelledData.recycle();
  mParcelledData=null;
}
Program: 24211
Project: 24211
Buggy source:
/** 
 * Reads the Parcel contents into this Bundle, typically in order for it to be passed through an IBinder connection.
 * @param parcel The parcel to overwrite this bundle from.
 */
public void readFromParcel(Parcel parcel){
  mParcelledData=parcel;
  mHasFds=mParcelledData.hasFileDescriptors();
  mFdsKnown=true;
}

Fixed version (ground truth):
/** 
 * Reads the Parcel contents into this Bundle, typically in order for it to be passed through an IBinder connection.
 * @param parcel The parcel to overwrite this bundle from.
 */
public void readFromParcel(Parcel parcel){
  int length=parcel.readInt();
  if (length < 0) {
    throw new RuntimeException("String_Node_Str" + length);
  }
  readFromParcelInner(parcel,length);
}
Program: 24212
Project: 24212
Buggy source:
private void readMapInternal(Map outVal,int N,ClassLoader loader){
  while (N > 0) {
    Object key=readValue(loader);
    Object value=readValue(loader);
    outVal.put(key,value);
    N--;
  }
}

Fixed version (ground truth):
void readMapInternal(Map outVal,int N,ClassLoader loader){
  while (N > 0) {
    Object key=readValue(loader);
    Object value=readValue(loader);
    outVal.put(key,value);
    N--;
  }
}