Program: 87993
Project: 87993
Buggy source:
/** 
 * Computes the actual node size, based on the cached addresses of the children nodes. Each node stores its tentative address. During dictionary address computing, these are not final, but they can be used to compute the node size (the node size depends on the address of the children because the number of bytes necessary to store an address depends on its numeric value.
 * @param node the node to compute the size of.
 * @param dict the dictionary in which the word/attributes are to be found.
 */
private static void computeActualNodeSize(Node node,FusionDictionary dict){
  int size=getGroupCountSize(node);
  for (  CharGroup group : node.mData) {
    int groupSize=GROUP_FLAGS_SIZE + getGroupCharactersSize(group);
    if (group.isTerminal())     groupSize+=GROUP_FREQUENCY_SIZE;
    if (null != group.mChildren) {
      final int offsetBasePoint=groupSize + node.mCachedAddress + size;
      final int offset=group.mChildren.mCachedAddress - offsetBasePoint;
      groupSize+=getByteSize(offset);
    }
    groupSize+=getShortcutListSize(group.mShortcutTargets);
    if (null != group.mBigrams) {
      for (      WeightedString bigram : group.mBigrams) {
        final int offsetBasePoint=groupSize + node.mCachedAddress + size+ GROUP_FLAGS_SIZE;
        final int addressOfBigram=findAddressOfWord(dict,bigram.mWord);
        final int offset=addressOfBigram - offsetBasePoint;
        groupSize+=getByteSize(offset) + GROUP_FLAGS_SIZE;
      }
    }
    group.mCachedSize=groupSize;
    size+=groupSize;
  }
  node.mCachedSize=size;
}

Fixed version (ground truth):
/** 
 * Computes the actual node size, based on the cached addresses of the children nodes. Each node stores its tentative address. During dictionary address computing, these are not final, but they can be used to compute the node size (the node size depends on the address of the children because the number of bytes necessary to store an address depends on its numeric value. The return value indicates whether the node contents (as in, any of the addresses stored in the cache fields) have changed with respect to their previous value.
 * @param node the node to compute the size of.
 * @param dict the dictionary in which the word/attributes are to be found.
 * @return false if none of the cached addresses inside the node changed, true otherwise.
 */
private static boolean computeActualNodeSize(Node node,FusionDictionary dict){
  boolean changed=false;
  int size=getGroupCountSize(node);
  for (  CharGroup group : node.mData) {
    if (group.mCachedAddress != node.mCachedAddress + size) {
      changed=true;
      group.mCachedAddress=node.mCachedAddress + size;
    }
    int groupSize=GROUP_FLAGS_SIZE + getGroupCharactersSize(group);
    if (group.isTerminal())     groupSize+=GROUP_FREQUENCY_SIZE;
    if (null != group.mChildren) {
      final int offsetBasePoint=groupSize + node.mCachedAddress + size;
      final int offset=group.mChildren.mCachedAddress - offsetBasePoint;
      groupSize+=getByteSize(offset);
    }
    groupSize+=getShortcutListSize(group.mShortcutTargets);
    if (null != group.mBigrams) {
      for (      WeightedString bigram : group.mBigrams) {
        final int offsetBasePoint=groupSize + node.mCachedAddress + size+ GROUP_FLAGS_SIZE;
        final int addressOfBigram=findAddressOfWord(dict,bigram.mWord);
        final int offset=addressOfBigram - offsetBasePoint;
        groupSize+=getByteSize(offset) + GROUP_FLAGS_SIZE;
      }
    }
    group.mCachedSize=groupSize;
    size+=groupSize;
  }
  if (node.mCachedSize != size) {
    node.mCachedSize=size;
    changed=true;
  }
  return changed;
}