Program: 62101
Project: 62101
Buggy source:
public static SHAPE systemFontCharacterToSHAPE(String fontName,int fontStyle,int fontSize,char character){
  List<SHAPERECORD> retList=new ArrayList<>();
  Font f=new Font(fontName,fontStyle,fontSize);
  GlyphVector v=f.createGlyphVector((new JPanel()).getFontMetrics(f).getFontRenderContext(),"String_Node_Str" + character);
  Shape shp=v.getOutline();
  double points[]=new double[6];
  double lastX=0;
  double lastY=0;
  double startX=0;
  double startY=0;
  for (PathIterator it=shp.getPathIterator(null); !it.isDone(); it.next()) {
    int type=it.currentSegment(points);
switch (type) {
case PathIterator.SEG_MOVETO:
      lastX=points[0];
    lastY=points[1];
  startX=lastX;
startY=lastY;
StyleChangeRecord scr=new StyleChangeRecord();
scr.stateMoveTo=true;
scr.moveDeltaX=(int)Math.round(points[0]);
scr.moveDeltaY=(int)Math.round(points[1]);
scr.moveBits=SWFOutputStream.getNeededBitsS(scr.moveDeltaX,scr.moveDeltaY);
retList.add(scr);
break;
case PathIterator.SEG_LINETO:
StraightEdgeRecord ser=new StraightEdgeRecord();
ser.generalLineFlag=true;
ser.deltaX=(int)Math.round((points[0] - lastX));
ser.deltaY=(int)Math.round((points[1] - lastY));
ser.numBits=SWFOutputStream.getNeededBitsS(ser.deltaX,ser.deltaY) - 2;
if (ser.numBits < 0) {
ser.numBits=0;
}
retList.add(ser);
lastX=points[0];
lastY=points[1];
break;
case PathIterator.SEG_CUBICTO:
double cubicCoords[]=new double[]{lastX,lastY,points[0],points[1],points[2],points[3],points[4],points[5]};
double quadCoords[][]=approximateCubic(cubicCoords);
for (int i=0; i < quadCoords.length; i++) {
CurvedEdgeRecord cer=new CurvedEdgeRecord();
cer.controlDeltaX=(int)Math.round((quadCoords[i][0] - lastX));
cer.controlDeltaY=(int)Math.round((quadCoords[i][1] - lastY));
cer.anchorDeltaX=(int)Math.round((quadCoords[i][2] - quadCoords[i][0]));
cer.anchorDeltaY=(int)Math.round((quadCoords[i][3] - quadCoords[i][1]));
cer.numBits=SWFOutputStream.getNeededBitsS(cer.controlDeltaX,cer.controlDeltaY,cer.anchorDeltaX,cer.anchorDeltaY) - 2;
if (cer.numBits < 0) {
cer.numBits=0;
}
lastX=quadCoords[i][2];
lastY=quadCoords[i][3];
retList.add(cer);
}
break;
case PathIterator.SEG_QUADTO:
CurvedEdgeRecord cer=new CurvedEdgeRecord();
cer.controlDeltaX=(int)Math.round((points[0] - lastX));
cer.controlDeltaY=(int)Math.round((points[1] - lastY));
cer.anchorDeltaX=(int)Math.round((points[2] - points[0]));
cer.anchorDeltaY=(int)Math.round((points[3] - points[1]));
cer.numBits=SWFOutputStream.getNeededBitsS(cer.controlDeltaX,cer.controlDeltaY,cer.anchorDeltaX,cer.anchorDeltaY) - 2;
if (cer.numBits < 0) {
cer.numBits=0;
}
retList.add(cer);
lastX=points[2];
lastY=points[3];
break;
case PathIterator.SEG_CLOSE:
if ((startX == lastX) && (startY == lastY)) {
break;
}
StraightEdgeRecord closeSer=new StraightEdgeRecord();
closeSer.generalLineFlag=true;
closeSer.deltaX=(int)Math.round((startX - lastX));
closeSer.deltaY=(int)Math.round((startY - lastY));
closeSer.numBits=SWFOutputStream.getNeededBitsS(closeSer.deltaX,closeSer.deltaY) - 2;
if (closeSer.numBits < 0) {
closeSer.numBits=0;
}
retList.add(closeSer);
lastX=startX;
lastY=startY;
break;
}
}
SHAPE shape=new SHAPE();
StyleChangeRecord init;
if (!retList.isEmpty() && retList.get(0) instanceof StyleChangeRecord) {
init=(StyleChangeRecord)retList.get(0);
}
 else {
init=new StyleChangeRecord();
retList.add(0,init);
}
retList.add(new EndShapeRecord());
init.stateFillStyle0=true;
init.fillStyle0=1;
shape.shapeRecords=retList;
shape.numFillBits=1;
shape.numLineBits=0;
return shape;
}

Fixed version (ground truth):
public static SHAPE systemFontCharacterToSHAPE(String fontName,int fontStyle,int fontSize,char character){
  List<SHAPERECORD> retList=new ArrayList<>();
  Font f=new Font(fontName,fontStyle,fontSize);
  GlyphVector v=f.createGlyphVector((new JPanel()).getFontMetrics(f).getFontRenderContext(),"String_Node_Str" + character);
  Shape shp=v.getOutline();
  double points[]=new double[6];
  int lastX=0;
  int lastY=0;
  int startX=0;
  int startY=0;
  for (PathIterator it=shp.getPathIterator(null); !it.isDone(); it.next()) {
    int type=it.currentSegment(points);
switch (type) {
case PathIterator.SEG_MOVETO:
      StyleChangeRecord scr=new StyleChangeRecord();
    scr.stateMoveTo=true;
  scr.moveDeltaX=(int)Math.round(points[0]);
scr.moveDeltaY=(int)Math.round(points[1]);
scr.moveBits=SWFOutputStream.getNeededBitsS(scr.moveDeltaX,scr.moveDeltaY);
retList.add(scr);
lastX=(int)Math.round(points[0]);
lastY=(int)Math.round(points[1]);
startX=lastX;
startY=lastY;
break;
case PathIterator.SEG_LINETO:
StraightEdgeRecord ser=new StraightEdgeRecord();
ser.generalLineFlag=true;
ser.deltaX=((int)Math.round(points[0])) - lastX;
ser.deltaY=((int)Math.round(points[1])) - lastY;
ser.numBits=SWFOutputStream.getNeededBitsS(ser.deltaX,ser.deltaY) - 2;
if (ser.numBits < 0) {
ser.numBits=0;
}
retList.add(ser);
lastX=(int)Math.round(points[0]);
lastY=(int)Math.round(points[1]);
break;
case PathIterator.SEG_CUBICTO:
double cubicCoords[]=new double[]{lastX,lastY,Math.round(points[0]),Math.round(points[1]),Math.round(points[2]),Math.round(points[3]),Math.round(points[4]),Math.round(points[5])};
double quadCoords[][]=approximateCubic(cubicCoords);
for (int i=0; i < quadCoords.length; i++) {
CurvedEdgeRecord cer=new CurvedEdgeRecord();
cer.controlDeltaX=((int)Math.round(quadCoords[i][0])) - lastX;
cer.controlDeltaY=((int)Math.round(quadCoords[i][1])) - lastY;
cer.anchorDeltaX=((int)Math.round(quadCoords[i][2])) - ((int)Math.round(quadCoords[i][0]));
cer.anchorDeltaY=((int)Math.round(quadCoords[i][3])) - ((int)Math.round(quadCoords[i][1]));
cer.numBits=SWFOutputStream.getNeededBitsS(cer.controlDeltaX,cer.controlDeltaY,cer.anchorDeltaX,cer.anchorDeltaY) - 2;
if (cer.numBits < 0) {
cer.numBits=0;
}
lastX=(int)Math.round(quadCoords[i][2]);
lastY=(int)Math.round(quadCoords[i][3]);
retList.add(cer);
}
break;
case PathIterator.SEG_QUADTO:
CurvedEdgeRecord cer=new CurvedEdgeRecord();
cer.controlDeltaX=((int)Math.round(points[0])) - lastX;
cer.controlDeltaY=((int)Math.round(points[1])) - lastY;
cer.anchorDeltaX=((int)Math.round(points[2])) - (int)Math.round(points[0]);
cer.anchorDeltaY=((int)Math.round(points[3])) - (int)Math.round(points[1]);
cer.numBits=SWFOutputStream.getNeededBitsS(cer.controlDeltaX,cer.controlDeltaY,cer.anchorDeltaX,cer.anchorDeltaY) - 2;
if (cer.numBits < 0) {
cer.numBits=0;
}
retList.add(cer);
lastX=(int)Math.round(points[2]);
lastY=(int)Math.round(points[3]);
break;
case PathIterator.SEG_CLOSE:
if ((startX == lastX) && (startY == lastY)) {
break;
}
StraightEdgeRecord closeSer=new StraightEdgeRecord();
closeSer.generalLineFlag=true;
closeSer.deltaX=(int)Math.round((startX - lastX));
closeSer.deltaY=(int)Math.round((startY - lastY));
closeSer.numBits=SWFOutputStream.getNeededBitsS(closeSer.deltaX,closeSer.deltaY) - 2;
if (closeSer.numBits < 0) {
closeSer.numBits=0;
}
retList.add(closeSer);
lastX=startX;
lastY=startY;
break;
}
}
SHAPE shape=new SHAPE();
StyleChangeRecord init;
if (!retList.isEmpty() && retList.get(0) instanceof StyleChangeRecord) {
init=(StyleChangeRecord)retList.get(0);
}
 else {
init=new StyleChangeRecord();
retList.add(0,init);
}
retList.add(new EndShapeRecord());
init.stateFillStyle0=true;
init.fillStyle0=1;
shape.shapeRecords=retList;
shape.numFillBits=1;
shape.numLineBits=0;
return shape;
}