Program: 61669
Project: 61669
Buggy source:
@Override public boolean setFormattedText(MissingCharacterHandler missingCharHandler,String formattedText,String[] texts) throws ParseException {
  List<TEXTRECORD> oldTextRecords=textRecords;
  try {
    TextLexer lexer=new TextLexer(new StringReader(formattedText));
    ParsedSymbol s=null;
    textRecords=new ArrayList<>();
    RGB color=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();
    int textIdx=0;
    while ((s=lexer.yylex()) != null) {
switch (s.type) {
case PARAMETER:
        String paramName=(String)s.values[0];
      String paramValue=(String)s.values[1];
switch (paramName) {
case "String_Node_Str":
      Matcher m=Pattern.compile("String_Node_Str").matcher(paramValue);
    if (m.matches()) {
      color=new RGB(Integer.parseInt(m.group(1),16),Integer.parseInt(m.group(2),16),Integer.parseInt(m.group(3),16));
    }
 else {
      throw new ParseException("String_Node_Str",lexer.yyline());
    }
  break;
case "String_Node_Str":
try {
  fontId=Integer.parseInt(paramValue);
  for (  Tag t : swf.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:
String txt=(texts == null || textIdx >= texts.length) ? (String)s.values[0] : texts[textIdx++];
if (txt == null || (font == null && txt.isEmpty())) {
continue;
}
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 (color != null) {
tr.textColor=color;
tr.styleFlagsHasColor=true;
color=null;
}
if (x != null) {
tr.xOffset=x;
tr.styleFlagsHasXOffset=true;
x=null;
}
if (y != null) {
tr.yOffset=y;
tr.styleFlagsHasYOffset=true;
y=null;
}
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(c)) {
if (!missingCharHandler.handle(font,c)) {
return false;
}
}
if (nextChar != null && !font.containsChar(nextChar)) {
if (!missingCharHandler.handle(font,nextChar)) {
return false;
}
}
tr.glyphEntries[i]=new GLYPHENTRY();
tr.glyphEntries[i].glyphIndex=font.charToGlyph(c);
int advance;
if (font.hasLayout()) {
int kerningAdjustment=0;
if (nextChar != null) {
kerningAdjustment=font.getGlyphKerningAdjustment(tr.glyphEntries[i].glyphIndex,font.charToGlyph(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(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName,font.getFontStyle(),(int)(textHeight / SWF.unitDivisor),c,nextChar));
}
tr.glyphEntries[i].glyphAdvance=advance;
currentX+=advance;
}
if (currentX > maxX) {
maxX=currentX;
}
if (currentX < minX) {
minX=currentX;
}
break;
}
}
this.textMatrix=textMatrix;
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,String formattedText,String[] texts) throws ParseException {
  List<TEXTRECORD> oldTextRecords=textRecords;
  try {
    TextLexer lexer=new TextLexer(new StringReader(formattedText));
    ParsedSymbol s=null;
    textRecords=new ArrayList<>();
    RGB color=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();
    int textIdx=0;
    while ((s=lexer.yylex()) != null) {
switch (s.type) {
case PARAMETER:
        String paramName=(String)s.values[0];
      String paramValue=(String)s.values[1];
switch (paramName) {
case "String_Node_Str":
      Matcher m=Pattern.compile("String_Node_Str").matcher(paramValue);
    if (m.matches()) {
      color=new RGB(Integer.parseInt(m.group(1),16),Integer.parseInt(m.group(2),16),Integer.parseInt(m.group(3),16));
    }
 else {
      throw new ParseException("String_Node_Str",lexer.yyline());
    }
  break;
case "String_Node_Str":
try {
  fontId=Integer.parseInt(paramValue);
  for (  Tag t : swf.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:
String txt=(texts == null || textIdx >= texts.length) ? (String)s.values[0] : texts[textIdx++];
if (txt == null || (font == null && txt.isEmpty())) {
continue;
}
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 (color != null) {
tr.textColor=color;
tr.styleFlagsHasColor=true;
color=null;
}
if (x != null) {
tr.xOffset=x;
tr.styleFlagsHasXOffset=true;
x=null;
}
if (y != null) {
tr.yOffset=y;
tr.styleFlagsHasYOffset=true;
y=null;
}
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(c)) {
if (!missingCharHandler.handle(font,c)) {
return false;
}
}
if (nextChar != null && !font.containsChar(nextChar)) {
if (!missingCharHandler.handle(font,nextChar)) {
return false;
}
}
tr.glyphEntries[i]=new GLYPHENTRY();
tr.glyphEntries[i].glyphIndex=font.charToGlyph(c);
int advance;
if (font.hasLayout()) {
int kerningAdjustment=0;
if (nextChar != null) {
kerningAdjustment=font.getGlyphKerningAdjustment(tr.glyphEntries[i].glyphIndex,font.charToGlyph(nextChar));
}
advance=(int)Math.round(font.getDivider() * ((double)textHeight * font.getGlyphAdvance(tr.glyphEntries[i].glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0));
}
 else {
advance=(int)Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName,font.getFontStyle(),(int)(textHeight / SWF.unitDivisor),c,nextChar));
}
tr.glyphEntries[i].glyphAdvance=advance;
currentX+=advance;
}
if (currentX > maxX) {
maxX=currentX;
}
if (currentX < minX) {
minX=currentX;
}
break;
}
}
this.textMatrix=textMatrix;
this.textBounds=textBounds;
}
 catch (IOException ex) {
textRecords=oldTextRecords;
return false;
}
catch (ParseException ex) {
textRecords=oldTextRecords;
throw ex;
}
return true;
}