Program: 70937
Project: 70937
Buggy source:
protected IReportItemExecutor prepareChildExecutor() throws Exception {
  if (prepareFirstChild) {
    if (fragment == null && nextOffset == -1) {
      DocumentExtension docExt=(DocumentExtension)content.getExtension(IContent.DOCUMENT_EXTENSION);
      if (docExt != null) {
        nextOffset=docExt.getFirstChild();
      }
    }
    if (fragment != null) {
      if (sections == null) {
        sections=fragment.getSections();
        nextSection=-1;
        useNextSection=true;
      }
    }
    prepareFirstChild=false;
  }
  if (fragment != null) {
    if (useNextSection) {
      useNextSection=false;
      nextSection++;
      if (sections == null || nextSection >= sections.length) {
        return null;
      }
      Object leftEdge=sections[nextSection][0];
      if (leftEdge == Segment.LEFT_MOST_EDGE) {
        DocumentExtension docExt=(DocumentExtension)content.getExtension(IContent.DOCUMENT_EXTENSION);
        if (docExt != null) {
          nextOffset=docExt.getFirstChild();
        }
      }
 else {
        InstanceIndex leftIndex=(InstanceIndex)leftEdge;
        InstanceID leftId=leftIndex.getInstanceID();
        long leftOffset=leftIndex.getOffset();
        if (leftOffset == -1) {
          DocumentExtension docExt=(DocumentExtension)content.getExtension(IContent.DOCUMENT_EXTENSION);
          if (docExt != null) {
            leftOffset=docExt.getFirstChild();
          }
        }
        if (leftOffset != -1) {
          IContent leftContent=reader.loadContent(leftOffset);
          InstanceID contentId=leftContent.getInstanceID();
          if (isSameInstance(contentId,leftId)) {
            nextOffset=leftIndex.getOffset();
          }
 else {
            DocumentExtension docExt=(DocumentExtension)leftContent.getExtension(IContent.DOCUMENT_EXTENSION);
            if (docExt != null) {
              nextOffset=docExt.getNext();
            }
          }
        }
        doSkipToExecutor(leftId,nextOffset);
        uniqueId=leftId.getUniqueID();
      }
    }
  }
  ReportItemExecutor childExecutor=doCreateExecutor(nextOffset);
  if (childExecutor != null) {
    IContent childContent=childExecutor.execute();
    if (childContent != null) {
      if (fragment != null) {
        InstanceID childId=childContent.getInstanceID();
        Fragment childFragment=fragment.getFragment(childId);
        if (childFragment != null) {
          childExecutor.setFragment(childFragment);
        }
        Object rightEdge=sections[nextSection][1];
        if (rightEdge != Segment.RIGHT_MOST_EDGE) {
          InstanceIndex rightIndex=(InstanceIndex)rightEdge;
          InstanceID rightId=rightIndex.getInstanceID();
          if (isSameInstance(rightId,childId)) {
            useNextSection=true;
          }
        }
      }
      DocumentExtension docExt=(DocumentExtension)childContent.getExtension(IContent.DOCUMENT_EXTENSION);
      if (docExt != null) {
        if (docExt.getIndex() == nextOffset) {
          nextOffset=docExt.getNext();
        }
      }
    }
  }
  return childExecutor;
}

Fixed version (ground truth):
protected IReportItemExecutor prepareChildExecutor() throws Exception {
  if (prepareFirstChild) {
    if (fragment == null && nextOffset == -1) {
      DocumentExtension docExt=(DocumentExtension)content.getExtension(IContent.DOCUMENT_EXTENSION);
      if (docExt != null) {
        nextOffset=docExt.getFirstChild();
      }
    }
    if (fragment != null) {
      if (sections == null) {
        sections=fragment.getSections();
        nextSection=-1;
        useNextSection=true;
      }
    }
    prepareFirstChild=false;
  }
  if (fragment != null) {
    if (useNextSection) {
      useNextSection=false;
      nextSection++;
      if (sections == null || nextSection >= sections.length) {
        return null;
      }
      Object leftEdge=sections[nextSection][0];
      if (leftEdge == Segment.LEFT_MOST_EDGE) {
        DocumentExtension docExt=(DocumentExtension)content.getExtension(IContent.DOCUMENT_EXTENSION);
        if (docExt != null) {
          nextOffset=docExt.getFirstChild();
        }
      }
 else {
        InstanceIndex leftIndex=(InstanceIndex)leftEdge;
        InstanceID leftId=leftIndex.getInstanceID();
        long leftOffset=leftIndex.getOffset();
        if (leftOffset == -1) {
          DocumentExtension docExt=(DocumentExtension)content.getExtension(IContent.DOCUMENT_EXTENSION);
          if (docExt != null) {
            leftOffset=docExt.getFirstChild();
          }
        }
        if (leftOffset != -1) {
          IContent leftContent=reader.loadContent(leftOffset);
          InstanceID contentId=leftContent.getInstanceID();
          if (isSameInstance(contentId,leftId)) {
            nextOffset=leftIndex.getOffset();
          }
 else {
            nextOffset=leftOffset;
          }
        }
        doSkipToExecutor(leftId,nextOffset);
        uniqueId=leftId.getUniqueID();
      }
    }
  }
  ReportItemExecutor childExecutor=doCreateExecutor(nextOffset);
  if (childExecutor != null) {
    IContent childContent=childExecutor.execute();
    if (childContent != null) {
      if (fragment != null) {
        InstanceID childId=childContent.getInstanceID();
        Fragment childFragment=fragment.getFragment(childId);
        if (childFragment != null) {
          childExecutor.setFragment(childFragment);
        }
        Object rightEdge=sections[nextSection][1];
        if (rightEdge != Segment.RIGHT_MOST_EDGE) {
          InstanceIndex rightIndex=(InstanceIndex)rightEdge;
          InstanceID rightId=rightIndex.getInstanceID();
          if (isSameInstance(rightId,childId)) {
            useNextSection=true;
          }
        }
      }
      DocumentExtension docExt=(DocumentExtension)childContent.getExtension(IContent.DOCUMENT_EXTENSION);
      if (docExt != null) {
        if (docExt.getIndex() == nextOffset) {
          nextOffset=docExt.getNext();
        }
      }
    }
  }
  return childExecutor;
}