Program: 17457
Project: 17457
Buggy source:
public IRegion match(IDocument iDocument,int offset){
  clear();
  IRegion region=null;
  this.document=iDocument;
  this.offset=offset;
  if (document != null && offset >= 0) {
    Iterator pairIterator=pairs.iterator();
    while (matchingPair == null && pairIterator.hasNext()) {
      Pair currentPair=(Pair)pairIterator.next();
      try {
        if (iDocument.get(offset - currentPair.getLength(),currentPair.getLength()).equals(currentPair.getRight())) {
          currentAnchor=CFMLPairMatcher.RIGHT;
          matchingPair=currentPair;
        }
 else         if (iDocument.get(offset - currentPair.getLength(),currentPair.getLength()).equals(currentPair.getLeft())) {
          currentAnchor=CFMLPairMatcher.LEFT;
          matchingPair=currentPair;
        }
      }
 catch (      BadLocationException e) {
      }
    }
    if (matchingPair != null) {
      try {
        int startOffset=offset - matchingPair.getLength();
        int matchDistance=findDistanceToMatch();
        if (matchDistance < 0) {
          region=new Region(startOffset + matchDistance - matchingPair.getLength(),0 - matchDistance);
        }
 else         if (matchDistance == 0) {
          if (currentAnchor == CFMLPairMatcher.RIGHT) {
            region=new Region(startOffset + matchDistance - matchingPair.getLength(),matchingPair.getLength());
          }
 else {
            region=new Region(startOffset,matchDistance + 2 * matchingPair.getLength());
          }
        }
 else         if (matchDistance > 0) {
          region=new Region(startOffset,matchDistance + 2 * matchingPair.getLength());
        }
      }
 catch (      UnableToFindMatchException e) {
        region=null;
      }
catch (      UnsetAnchorException e) {
        region=null;
      }
    }
  }
  return region;
}

Fixed version (ground truth):
public IRegion match(IDocument iDocument,int offset){
  clear();
  IRegion region=null;
  this.document=iDocument;
  this.offset=offset;
  if (document != null && offset >= 0) {
    Iterator pairIterator=pairs.iterator();
    while (matchingPair == null && pairIterator.hasNext()) {
      Pair currentPair=(Pair)pairIterator.next();
      try {
        if (iDocument.get(offset - currentPair.getLength(),currentPair.getLength()).equals(currentPair.getRight())) {
          currentAnchor=CFMLPairMatcher.RIGHT;
          matchingPair=currentPair;
        }
 else         if (iDocument.get(offset - currentPair.getLength(),currentPair.getLength()).equals(currentPair.getLeft())) {
          currentAnchor=CFMLPairMatcher.LEFT;
          matchingPair=currentPair;
        }
      }
 catch (      BadLocationException e) {
      }
    }
    if (matchingPair != null) {
      try {
        int startOffset=offset - matchingPair.getLength();
        int matchDistance=findDistanceToMatch();
        if (matchDistance < 0) {
          region=new Region(startOffset + matchDistance - matchingPair.getLength(),Math.abs(matchDistance) + 2 * matchingPair.getLength());
        }
 else         if (matchDistance == 0) {
          if (currentAnchor == CFMLPairMatcher.RIGHT) {
            region=new Region(startOffset - 1,2 * matchingPair.getLength());
          }
 else {
            region=new Region(startOffset,2 * matchingPair.getLength());
          }
        }
 else         if (matchDistance > 0) {
          region=new Region(startOffset,matchDistance + 2 * matchingPair.getLength());
        }
      }
 catch (      UnableToFindMatchException e) {
        region=null;
      }
catch (      UnsetAnchorException e) {
        region=null;
      }
    }
  }
  return region;
}