Program: 76460
Project: 76460
Buggy source:
public IPageContent executeMasterPage(int pageNo,MasterPageDesign masterPage){
  IReportContent reportContent=context.getReportContent();
  IPageContent pageContent=reportContent.createPageContent();
  pageContent.setGenerateBy(masterPage);
  pageContent.setPageNumber(pageNo);
  context.setPageNumber(pageNo);
  if (masterPage instanceof SimpleMasterPageDesign) {
    TOCBuilder tocBuilder=context.getTOCBuilder();
    context.setTOCBuilder(null);
    context.setExecutingMasterPage(true);
    SimpleMasterPageDesign pageDesign=(SimpleMasterPageDesign)masterPage;
    pageContent.setStyleClass(masterPage.getStyleName());
    InstanceID iid=new InstanceID(null,pageDesign.getID(),null);
    pageContent.setInstanceID(iid);
    IContent header=reportContent.createContainerContent();
    header.setStyleClass(masterPage.getStyleName());
    pageContent.setPageHeader(header);
    header.setParent(pageContent);
    IContentEmitter domEmitter=new DOMBuilderEmitter(header);
    ExecutorManager manager=new ExecutorManager(context,domEmitter,executorContext);
    for (int i=0; i < pageDesign.getHeaderCount(); i++) {
      ReportItemDesign design=pageDesign.getHeader(i);
      ReportItemExecutor executor=manager.createExecutor(null,design);
      executor.execute(design,domEmitter);
    }
    IContent body=reportContent.createContainerContent();
    pageContent.setPageBody(body);
    body.setParent(pageContent);
    IContent footer=reportContent.createContainerContent();
    footer.setStyleClass(masterPage.getStyleName());
    pageContent.setPageFooter(footer);
    footer.setParent(pageContent);
    domEmitter=new DOMBuilderEmitter(footer);
    manager=new ExecutorManager(context,domEmitter,executorContext);
    for (int i=0; i < pageDesign.getFooterCount(); i++) {
      ReportItemDesign design=pageDesign.getFooter(i);
      ReportItemExecutor executor=manager.createExecutor(null,design);
      executor.execute(design,domEmitter);
    }
    context.setExecutingMasterPage(false);
    context.setTOCBuilder(tocBuilder);
  }
  return pageContent;
}

Fixed version (ground truth):
public IPageContent executeMasterPage(int pageNo,MasterPageDesign masterPage){
  IReportContent reportContent=context.getReportContent();
  IPageContent pageContent=reportContent.createPageContent();
  pageContent.setGenerateBy(masterPage);
  pageContent.setPageNumber(pageNo);
  context.setPageNumber(pageNo);
  if (masterPage instanceof SimpleMasterPageDesign) {
    TOCBuilder tocBuilder=context.getTOCBuilder();
    context.setTOCBuilder(null);
    context.setExecutingMasterPage(true);
    SimpleMasterPageDesign pageDesign=(SimpleMasterPageDesign)masterPage;
    InstanceID iid=new InstanceID(null,pageDesign.getID(),null);
    pageContent.setInstanceID(iid);
    IContent header=reportContent.createContainerContent();
    pageContent.setPageHeader(header);
    header.setParent(pageContent);
    IContentEmitter domEmitter=new DOMBuilderEmitter(header);
    ExecutorManager manager=new ExecutorManager(context,domEmitter,executorContext);
    for (int i=0; i < pageDesign.getHeaderCount(); i++) {
      ReportItemDesign design=pageDesign.getHeader(i);
      ReportItemExecutor executor=manager.createExecutor(null,design);
      executor.execute(design,domEmitter);
    }
    IContent body=reportContent.createContainerContent();
    pageContent.setPageBody(body);
    body.setParent(pageContent);
    IContent footer=reportContent.createContainerContent();
    pageContent.setPageFooter(footer);
    footer.setParent(pageContent);
    domEmitter=new DOMBuilderEmitter(footer);
    manager=new ExecutorManager(context,domEmitter,executorContext);
    for (int i=0; i < pageDesign.getFooterCount(); i++) {
      ReportItemDesign design=pageDesign.getFooter(i);
      ReportItemExecutor executor=manager.createExecutor(null,design);
      executor.execute(design,domEmitter);
    }
    context.setExecutingMasterPage(false);
    context.setTOCBuilder(tocBuilder);
  }
  return pageContent;
}