Program: 70997
Project: 70997
Buggy source:
protected Object readDesign(DataInputStream in) throws IOException {
  short designType=IOUtil.readShort(in);
  byte[] buffer=IOUtil.readBytes(in);
  DataInputStream dis=new DataInputStream(new ByteArrayInputStream(buffer));
switch (designType) {
case SIMPLE_MASTER_PAGE_DESIGN:
{
      SimpleMasterPageDesign masterPage=new SimpleMasterPageDesign();
      readSimpleMasterPage(dis,masterPage);
      int count=IOUtil.readInt(in);
      for (int i=0; i < count; i++) {
        ReportItemDesign item=(ReportItemDesign)readDesign(in);
        masterPage.addHeader(item);
      }
      count=IOUtil.readInt(in);
      for (int i=0; i < count; i++) {
        ReportItemDesign item=(ReportItemDesign)readDesign(in);
        masterPage.addFooter(item);
      }
      return masterPage;
    }
case GRID_DESIGN:
{
    GridItemDesign grid=new GridItemDesign();
    readGrid(dis,grid);
    int count=IOUtil.readInt(in);
    for (int i=0; i < count; i++) {
      RowDesign row=(RowDesign)readDesign(in);
      grid.addRow(row);
    }
    return grid;
  }
case FREE_FORM_DESIGN:
{
  FreeFormItemDesign freeForm=new FreeFormItemDesign();
  readFreeForm(dis,freeForm);
  int count=IOUtil.readInt(in);
  for (int i=0; i < count; i++) {
    ReportItemDesign item=(ReportItemDesign)readDesign(in);
    freeForm.addItem(item);
  }
  return freeForm;
}
case ROW_DESIGN:
{
RowDesign row=new RowDesign();
readRow(dis,row);
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
  CellDesign cell=(CellDesign)readDesign(in);
  row.addCell(cell);
}
return row;
}
case CELL_DESIGN:
{
CellDesign cell=new CellDesign();
readCell(dis,cell);
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
ReportItemDesign item=(ReportItemDesign)readDesign(in);
cell.addContent(item);
}
return cell;
}
case LIST_DESIGN:
{
ListItemDesign list=new ListItemDesign();
readList(dis,list);
if (IOUtil.readBool(in)) {
ListBandDesign header=(ListBandDesign)readDesign(in);
list.setHeader(header);
}
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
ListGroupDesign group=(ListGroupDesign)readDesign(in);
list.addGroup(group);
}
if (IOUtil.readBool(in)) {
ListBandDesign detail=(ListBandDesign)readDesign(in);
list.setDetail(detail);
}
if (IOUtil.readBool(in)) {
ListBandDesign footer=(ListBandDesign)readDesign(in);
list.setFooter(footer);
}
return list;
}
case LIST_GROUP_DESIGN:
{
ListGroupDesign listGroup=new ListGroupDesign();
readListGroup(dis,listGroup);
if (IOUtil.readBool(in)) {
ListBandDesign groupHeader=(ListBandDesign)readDesign(in);
listGroup.setHeader(groupHeader);
}
if (IOUtil.readBool(in)) {
ListBandDesign footer=(ListBandDesign)readDesign(in);
listGroup.setFooter(footer);
}
return listGroup;
}
case LIST_BAND_DESIGN:
{
ListBandDesign listBand=new ListBandDesign();
readListBand(dis,listBand);
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
ReportItemDesign item=(ReportItemDesign)readDesign(in);
listBand.addContent(item);
}
return listBand;
}
case TABLE_DESIGN:
{
TableItemDesign table=new TableItemDesign();
readTable(dis,table);
if (IOUtil.readBool(in)) {
TableBandDesign header=(TableBandDesign)readDesign(in);
table.setHeader(header);
}
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
TableGroupDesign group=(TableGroupDesign)readDesign(in);
table.addGroup(group);
}
if (IOUtil.readBool(in)) {
TableBandDesign detail=(TableBandDesign)readDesign(in);
table.setDetail(detail);
}
if (IOUtil.readBool(in)) {
TableBandDesign footer=(TableBandDesign)readDesign(in);
table.setFooter(footer);
}
return table;
}
case TABLE_GROUP_DESIGN:
{
TableGroupDesign tableGroup=new TableGroupDesign();
readTableGroup(dis,tableGroup);
if (IOUtil.readBool(in)) {
TableBandDesign groupHeader=(TableBandDesign)readDesign(in);
tableGroup.setHeader(groupHeader);
}
if (IOUtil.readBool(in)) {
TableBandDesign footer=(TableBandDesign)readDesign(in);
tableGroup.setFooter(footer);
}
return tableGroup;
}
case TABLE_BAND_DESIGN:
{
TableBandDesign band=new TableBandDesign();
readTableBand(dis,band);
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
RowDesign row=(RowDesign)readDesign(in);
band.addContent(row);
}
return band;
}
case LABEL_DESIGN:
{
LabelItemDesign design=new LabelItemDesign();
readLabel(dis,design);
return design;
}
case TEXT_DESIGN:
{
TextItemDesign design=new TextItemDesign();
readText(dis,design);
return design;
}
case DATA_DESIGN:
{
DataItemDesign design=new DataItemDesign();
readData(dis,design);
return design;
}
case MULTI_LINE_DESIGN:
{
DynamicTextItemDesign design=new DynamicTextItemDesign();
readDynamicText(dis,design);
return design;
}
case IMAGE_DESIGN:
{
ImageItemDesign design=new ImageItemDesign();
readImage(dis,design);
return design;
}
case TEMPLATE_DESIGN:
{
TemplateDesign design=new TemplateDesign();
readTemplate(dis,design);
return design;
}
case EXTENDED_DESIGN:
{
ExtendedItemDesign design=new ExtendedItemDesign();
readExtended(dis,design);
if (version >= ENGINE_IR_VERSION_3) {
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
design.getChildren().add(readDesign(in));
}
}
return design;
}
case AUTO_TEXT_DESIGN:
{
AutoTextItemDesign design=new AutoTextItemDesign();
readAutoText(dis,design);
return design;
}
default :
throw new IOException("String_Node_Str" + designType);
}
}

Fixed version (ground truth):
protected Object readDesign(DataInputStream in) throws IOException {
  short designType=IOUtil.readShort(in);
  byte[] buffer=IOUtil.readBytes(in);
  DataInputStream dis=new DataInputStream(new ByteArrayInputStream(buffer));
switch (designType) {
case SIMPLE_MASTER_PAGE_DESIGN:
{
      SimpleMasterPageDesign masterPage=new SimpleMasterPageDesign();
      readSimpleMasterPage(dis,masterPage);
      int count=IOUtil.readInt(in);
      for (int i=0; i < count; i++) {
        ReportItemDesign item=(ReportItemDesign)readDesign(in);
        masterPage.addHeader(item);
      }
      count=IOUtil.readInt(in);
      for (int i=0; i < count; i++) {
        ReportItemDesign item=(ReportItemDesign)readDesign(in);
        masterPage.addFooter(item);
      }
      processClassStyleCompatibility(masterPage);
      return masterPage;
    }
case GRID_DESIGN:
{
    GridItemDesign grid=new GridItemDesign();
    readGrid(dis,grid);
    int count=IOUtil.readInt(in);
    for (int i=0; i < count; i++) {
      RowDesign row=(RowDesign)readDesign(in);
      grid.addRow(row);
    }
    processClassStyleCompatibility(grid);
    return grid;
  }
case FREE_FORM_DESIGN:
{
  FreeFormItemDesign freeForm=new FreeFormItemDesign();
  readFreeForm(dis,freeForm);
  int count=IOUtil.readInt(in);
  for (int i=0; i < count; i++) {
    ReportItemDesign item=(ReportItemDesign)readDesign(in);
    freeForm.addItem(item);
  }
  processClassStyleCompatibility(freeForm);
  return freeForm;
}
case ROW_DESIGN:
{
RowDesign row=new RowDesign();
readRow(dis,row);
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
  CellDesign cell=(CellDesign)readDesign(in);
  row.addCell(cell);
}
processClassStyleCompatibility(row);
return row;
}
case CELL_DESIGN:
{
CellDesign cell=new CellDesign();
readCell(dis,cell);
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
ReportItemDesign item=(ReportItemDesign)readDesign(in);
cell.addContent(item);
}
processClassStyleCompatibility(cell);
return cell;
}
case LIST_DESIGN:
{
ListItemDesign list=new ListItemDesign();
readList(dis,list);
if (IOUtil.readBool(in)) {
ListBandDesign header=(ListBandDesign)readDesign(in);
list.setHeader(header);
}
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
ListGroupDesign group=(ListGroupDesign)readDesign(in);
list.addGroup(group);
}
if (IOUtil.readBool(in)) {
ListBandDesign detail=(ListBandDesign)readDesign(in);
list.setDetail(detail);
}
if (IOUtil.readBool(in)) {
ListBandDesign footer=(ListBandDesign)readDesign(in);
list.setFooter(footer);
}
processClassStyleCompatibility(list);
return list;
}
case LIST_GROUP_DESIGN:
{
ListGroupDesign listGroup=new ListGroupDesign();
readListGroup(dis,listGroup);
if (IOUtil.readBool(in)) {
ListBandDesign groupHeader=(ListBandDesign)readDesign(in);
listGroup.setHeader(groupHeader);
}
if (IOUtil.readBool(in)) {
ListBandDesign footer=(ListBandDesign)readDesign(in);
listGroup.setFooter(footer);
}
processClassStyleCompatibility(listGroup);
return listGroup;
}
case LIST_BAND_DESIGN:
{
ListBandDesign listBand=new ListBandDesign();
readListBand(dis,listBand);
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
ReportItemDesign item=(ReportItemDesign)readDesign(in);
listBand.addContent(item);
}
processClassStyleCompatibility(listBand);
return listBand;
}
case TABLE_DESIGN:
{
TableItemDesign table=new TableItemDesign();
readTable(dis,table);
if (IOUtil.readBool(in)) {
TableBandDesign header=(TableBandDesign)readDesign(in);
table.setHeader(header);
}
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
TableGroupDesign group=(TableGroupDesign)readDesign(in);
table.addGroup(group);
}
if (IOUtil.readBool(in)) {
TableBandDesign detail=(TableBandDesign)readDesign(in);
table.setDetail(detail);
}
if (IOUtil.readBool(in)) {
TableBandDesign footer=(TableBandDesign)readDesign(in);
table.setFooter(footer);
}
processClassStyleCompatibility(table);
return table;
}
case TABLE_GROUP_DESIGN:
{
TableGroupDesign tableGroup=new TableGroupDesign();
readTableGroup(dis,tableGroup);
if (IOUtil.readBool(in)) {
TableBandDesign groupHeader=(TableBandDesign)readDesign(in);
tableGroup.setHeader(groupHeader);
}
if (IOUtil.readBool(in)) {
TableBandDesign footer=(TableBandDesign)readDesign(in);
tableGroup.setFooter(footer);
}
processClassStyleCompatibility(tableGroup);
return tableGroup;
}
case TABLE_BAND_DESIGN:
{
TableBandDesign band=new TableBandDesign();
readTableBand(dis,band);
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
RowDesign row=(RowDesign)readDesign(in);
band.addContent(row);
}
processClassStyleCompatibility(band);
return band;
}
case LABEL_DESIGN:
{
LabelItemDesign design=new LabelItemDesign();
readLabel(dis,design);
processClassStyleCompatibility(design);
return design;
}
case TEXT_DESIGN:
{
TextItemDesign design=new TextItemDesign();
readText(dis,design);
processClassStyleCompatibility(design);
return design;
}
case DATA_DESIGN:
{
DataItemDesign design=new DataItemDesign();
readData(dis,design);
processClassStyleCompatibility(design);
return design;
}
case MULTI_LINE_DESIGN:
{
DynamicTextItemDesign design=new DynamicTextItemDesign();
readDynamicText(dis,design);
processClassStyleCompatibility(design);
return design;
}
case IMAGE_DESIGN:
{
ImageItemDesign design=new ImageItemDesign();
readImage(dis,design);
processClassStyleCompatibility(design);
return design;
}
case TEMPLATE_DESIGN:
{
TemplateDesign design=new TemplateDesign();
readTemplate(dis,design);
processClassStyleCompatibility(design);
return design;
}
case EXTENDED_DESIGN:
{
ExtendedItemDesign design=new ExtendedItemDesign();
readExtended(dis,design);
if (version >= ENGINE_IR_VERSION_3) {
int count=IOUtil.readInt(in);
for (int i=0; i < count; i++) {
design.getChildren().add(readDesign(in));
}
}
processClassStyleCompatibility(design);
return design;
}
case AUTO_TEXT_DESIGN:
{
AutoTextItemDesign design=new AutoTextItemDesign();
readAutoText(dis,design);
processClassStyleCompatibility(design);
return design;
}
default :
throw new IOException("String_Node_Str" + designType);
}
}