Program: 96369
Project: 96369
Buggy source:
/** 
 * Names the given hierarchy container. <br>  If the managed component has a unique name, this name is used. Otherwise a name (unique for the hierachy level) is created. 
 * @param hierarchyContainer the hierarchyContainer to name, if hierarchyContainer is null,no action is performed and no exception is thrown.
 */
private synchronized void name(SwtHierarchyContainer hierarchyContainer){
  if (hierarchyContainer != null) {
    Widget component=hierarchyContainer.getComponentID().getRealComponent();
    Object compName=component.getData(SwtAUTHierarchyConstants.WIDGET_NAME);
    SwtHierarchyContainer hierarchyParent=null;
    Widget parent=SwtUtils.getWidgetParent(component);
    if (parent != null) {
      hierarchyParent=getHierarchyContainer(parent);
      hierarchyContainer.setParent(hierarchyParent);
    }
    if (hierarchyContainer.getName() != null && hierarchyContainer.getName().length() != 0) {
      return;
    }
    int count=1;
    String originalName=null;
    String newName=null;
    Object rcpCompId=component.getData(SwtAUTHierarchyConstants.RCP_NAME);
    boolean newNameGenerated=false;
    if (compName != null) {
      newName=compName.toString();
      originalName=compName.toString();
    }
 else     if (rcpCompId != null) {
      newName=rcpCompId.toString();
      originalName=rcpCompId.toString();
    }
    if (newName == null) {
      newNameGenerated=true;
      while (!isUniqueName(hierarchyParent,component,newName)) {
        newName=createName(component,count);
        count++;
      }
    }
 else {
      while (!isUniqueName(hierarchyParent,component,newName)) {
        newName=createName(originalName,count);
        count++;
      }
    }
    hierarchyContainer.setName(newName,newNameGenerated);
  }
}

Fixed version (ground truth):
/** 
 * Names the given hierarchy container. <br>  If the managed component has a unique name, this name is used. Otherwise a name (unique for the hierachy level) is created. 
 * @param hierarchyContainer the hierarchyContainer to name, if hierarchyContainer is null,no action is performed and no exception is thrown.
 */
private synchronized void name(SwtHierarchyContainer hierarchyContainer){
  if (hierarchyContainer != null) {
    Widget component=hierarchyContainer.getComponentID().getRealComponent();
    String compName=FindSWTComponentBP.getComponentName(component);
    SwtHierarchyContainer hierarchyParent=null;
    Widget parent=SwtUtils.getWidgetParent(component);
    if (parent != null) {
      hierarchyParent=getHierarchyContainer(parent);
      hierarchyContainer.setParent(hierarchyParent);
    }
    if (hierarchyContainer.getName() != null && hierarchyContainer.getName().length() != 0) {
      return;
    }
    int count=1;
    String originalName=null;
    String newName=null;
    Object rcpCompId=component.getData(SwtAUTHierarchyConstants.RCP_NAME);
    boolean newNameGenerated=false;
    if (compName != null) {
      newName=compName.toString();
      originalName=compName.toString();
    }
 else     if (rcpCompId != null) {
      newName=rcpCompId.toString();
      originalName=rcpCompId.toString();
    }
    if (newName == null) {
      newNameGenerated=true;
      while (!isUniqueName(hierarchyParent,component,newName)) {
        newName=createName(component,count);
        count++;
      }
    }
 else {
      while (!isUniqueName(hierarchyParent,component,newName)) {
        newName=createName(originalName,count);
        count++;
      }
    }
    hierarchyContainer.setName(newName,newNameGenerated);
  }
}