Program: 61900
Project: 61900
Buggy source:
@Override public boolean setFormattedText(MissingCharacterHandler missingCharHandler,List<Tag> tags,String text) throws ParseException {
  List<TEXTRECORD> oldTextRecords=textRecords;
  try {
    TextLexer lexer=new TextLexer(new StringReader(text));
    ParsedSymbol s=null;
    textRecords=new ArrayList<>();
    RGBA colorA=null;
    int fontId=-1;
    int textHeight=-1;
    FontTag font=null;
    String fontName=null;
    Integer x=null;
    Integer y=null;
    int currentX=0;
    int currentY=0;
    int maxX=Integer.MIN_VALUE;
    int minX=Integer.MAX_VALUE;
    MATRIX textMatrix=new MATRIX();
    textMatrix.hasRotate=false;
    textMatrix.hasScale=false;
    RECT textBounds=new RECT();
    while ((s=lexer.yylex()) != null) {
switch (s.type) {
case PARAMETER:
        String paramName=(String)s.values[0];
      String paramValue=(String)s.values[1];
    if (paramName.equals("String_Node_Str")) {
      Matcher m=Pattern.compile("String_Node_Str").matcher(paramValue);
      if (m.matches()) {
        colorA=new RGBA(Integer.parseInt(m.group(2),16),Integer.parseInt(m.group(3),16),Integer.parseInt(m.group(4),16),Integer.parseInt(m.group(1),16));
      }
 else {
        throw new ParseException("String_Node_Str",lexer.yyline());
      }
    }
switch (paramName) {
case "String_Node_Str":
    try {
      fontId=Integer.parseInt(paramValue);
      for (      Tag t : tags) {
        if (t instanceof FontTag) {
          if (((FontTag)t).getFontId() == fontId) {
            font=(FontTag)t;
            fontName=font.getSystemFontName();
            break;
          }
        }
      }
      if (font == null) {
        throw new ParseException("String_Node_Str",lexer.yyline());
      }
    }
 catch (    NumberFormatException nfe) {
      throw new ParseException("String_Node_Str",lexer.yyline());
    }
  break;
case "String_Node_Str":
try {
  textHeight=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
  throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
x=Integer.parseInt(paramValue);
currentX=x;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
y=Integer.parseInt(paramValue);
currentY=y;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textBounds.Xmin=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textBounds.Xmax=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textBounds.Ymin=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textBounds.Ymax=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.scaleX=Integer.parseInt(paramValue);
textMatrix.hasScale=true;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.scaleY=Integer.parseInt(paramValue);
textMatrix.hasScale=true;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.rotateSkew0=Integer.parseInt(paramValue);
textMatrix.hasRotate=true;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.rotateSkew1=Integer.parseInt(paramValue);
textMatrix.hasRotate=true;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.translateX=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.translateY=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
}
break;
case TEXT:
if (font == null) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
TEXTRECORD tr=new TEXTRECORD();
textRecords.add(tr);
if (fontId > -1) {
tr.fontId=fontId;
tr.textHeight=textHeight;
fontId=-1;
tr.styleFlagsHasFont=true;
}
if (colorA != null) {
tr.textColorA=colorA;
tr.styleFlagsHasColor=true;
colorA=null;
}
if (x != null) {
tr.xOffset=x;
tr.styleFlagsHasXOffset=true;
x=null;
}
if (y != null) {
tr.yOffset=y;
tr.styleFlagsHasYOffset=true;
y=null;
}
String txt=(String)s.values[0];
tr.glyphEntries=new GLYPHENTRY[txt.length()];
for (int i=0; i < txt.length(); i++) {
char c=txt.charAt(i);
Character nextChar=null;
if (i + 1 < txt.length()) {
nextChar=txt.charAt(i + 1);
}
if (!font.containsChar(tags,c)) {
if (!missingCharHandler.handle(font,tags,c)) {
return false;
}
}
if (nextChar != null && !font.containsChar(tags,nextChar)) {
if (!missingCharHandler.handle(font,tags,nextChar)) {
return false;
}
}
tr.glyphEntries[i]=new GLYPHENTRY();
tr.glyphEntries[i].glyphIndex=font.charToGlyph(tags,c);
int advance;
if (font.hasLayout()) {
int kerningAdjustment=0;
if (nextChar != null) {
kerningAdjustment=font.getGlyphKerningAdjustment(tags,tr.glyphEntries[i].glyphIndex,font.charToGlyph(tags,nextChar));
}
advance=(int)Math.round(20.0 * Math.round((double)textHeight * (font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)));
}
 else {
advance=(int)Math.round(20.0 * FontTag.getSystemFontAdvance(fontName,font.getFontStyle(),textHeight / 20,c,nextChar));
}
tr.glyphEntries[i].glyphAdvance=advance;
currentX+=advance;
}
if (currentX > maxX) {
maxX=currentX;
}
if (currentX < minX) {
minX=currentX;
}
break;
}
}
this.textRecords=textRecords;
this.textBounds=textBounds;
}
 catch (IOException ex) {
textRecords=oldTextRecords;
return false;
}
catch (ParseException ex) {
textRecords=oldTextRecords;
throw ex;
}
return true;
}

Fixed version (ground truth):
@Override public boolean setFormattedText(MissingCharacterHandler missingCharHandler,List<Tag> tags,String text) throws ParseException {
  List<TEXTRECORD> oldTextRecords=textRecords;
  try {
    TextLexer lexer=new TextLexer(new StringReader(text));
    ParsedSymbol s=null;
    textRecords=new ArrayList<>();
    RGBA colorA=null;
    int fontId=-1;
    int textHeight=-1;
    FontTag font=null;
    String fontName=null;
    Integer x=null;
    Integer y=null;
    int currentX=0;
    int currentY=0;
    int maxX=Integer.MIN_VALUE;
    int minX=Integer.MAX_VALUE;
    MATRIX textMatrix=new MATRIX();
    textMatrix.hasRotate=false;
    textMatrix.hasScale=false;
    RECT textBounds=new RECT();
    while ((s=lexer.yylex()) != null) {
switch (s.type) {
case PARAMETER:
        String paramName=(String)s.values[0];
      String paramValue=(String)s.values[1];
    if (paramName.equals("String_Node_Str")) {
      Matcher m=Pattern.compile("String_Node_Str").matcher(paramValue);
      if (m.matches()) {
        colorA=new RGBA(Integer.parseInt(m.group(2),16),Integer.parseInt(m.group(3),16),Integer.parseInt(m.group(4),16),Integer.parseInt(m.group(1),16));
      }
 else {
        throw new ParseException("String_Node_Str",lexer.yyline());
      }
    }
switch (paramName) {
case "String_Node_Str":
    try {
      fontId=Integer.parseInt(paramValue);
      for (      Tag t : tags) {
        if (t instanceof FontTag) {
          if (((FontTag)t).getFontId() == fontId) {
            font=(FontTag)t;
            fontName=font.getSystemFontName();
            break;
          }
        }
      }
      if (font == null) {
        throw new ParseException("String_Node_Str",lexer.yyline());
      }
    }
 catch (    NumberFormatException nfe) {
      throw new ParseException("String_Node_Str",lexer.yyline());
    }
  break;
case "String_Node_Str":
try {
  textHeight=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
  throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
x=Integer.parseInt(paramValue);
currentX=x;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
y=Integer.parseInt(paramValue);
currentY=y;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textBounds.Xmin=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textBounds.Xmax=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textBounds.Ymin=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textBounds.Ymax=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.scaleX=Integer.parseInt(paramValue);
textMatrix.hasScale=true;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.scaleY=Integer.parseInt(paramValue);
textMatrix.hasScale=true;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.rotateSkew0=Integer.parseInt(paramValue);
textMatrix.hasRotate=true;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.rotateSkew1=Integer.parseInt(paramValue);
textMatrix.hasRotate=true;
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.translateX=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
case "String_Node_Str":
try {
textMatrix.translateY=Integer.parseInt(paramValue);
}
 catch (NumberFormatException nfe) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
break;
}
break;
case TEXT:
if (font == null) {
throw new ParseException("String_Node_Str",lexer.yyline());
}
TEXTRECORD tr=new TEXTRECORD();
textRecords.add(tr);
if (fontId > -1) {
tr.fontId=fontId;
tr.textHeight=textHeight;
fontId=-1;
tr.styleFlagsHasFont=true;
}
if (colorA != null) {
tr.textColorA=colorA;
tr.styleFlagsHasColor=true;
colorA=null;
}
if (x != null) {
tr.xOffset=x;
tr.styleFlagsHasXOffset=true;
x=null;
}
if (y != null) {
tr.yOffset=y;
tr.styleFlagsHasYOffset=true;
y=null;
}
String txt=(String)s.values[0];
tr.glyphEntries=new GLYPHENTRY[txt.length()];
for (int i=0; i < txt.length(); i++) {
char c=txt.charAt(i);
Character nextChar=null;
if (i + 1 < txt.length()) {
nextChar=txt.charAt(i + 1);
}
if (!font.containsChar(tags,c)) {
if (!missingCharHandler.handle(font,tags,c)) {
return false;
}
}
if (nextChar != null && !font.containsChar(tags,nextChar)) {
if (!missingCharHandler.handle(font,tags,nextChar)) {
return false;
}
}
tr.glyphEntries[i]=new GLYPHENTRY();
tr.glyphEntries[i].glyphIndex=font.charToGlyph(tags,c);
int advance;
if (font.hasLayout()) {
int kerningAdjustment=0;
if (nextChar != null) {
kerningAdjustment=font.getGlyphKerningAdjustment(tags,tr.glyphEntries[i].glyphIndex,font.charToGlyph(tags,nextChar));
}
advance=(int)Math.round(font.getDivider() * Math.round((double)textHeight * (font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)));
}
 else {
advance=(int)Math.round(20.0 * FontTag.getSystemFontAdvance(fontName,font.getFontStyle(),textHeight / 20,c,nextChar));
}
tr.glyphEntries[i].glyphAdvance=advance;
currentX+=advance;
}
if (currentX > maxX) {
maxX=currentX;
}
if (currentX < minX) {
minX=currentX;
}
break;
}
}
this.textRecords=textRecords;
this.textBounds=textBounds;
}
 catch (IOException ex) {
textRecords=oldTextRecords;
return false;
}
catch (ParseException ex) {
textRecords=oldTextRecords;
throw ex;
}
return true;
}