Program: 51679
Project: 51679
Buggy source:
/** 
 * Apply   {@link CubeAcess} permissions to the query by filteringhierarchies, putting limits on the slicer, etc.  If some of the permissions can not be applied (user used expression like currentYear, which can not be computed prior to running query) the function returns array of limited members, which could not be applied. It means, that the we need to parse the results before showing them to the user.
 */
private ArrayList applyPermissions(CubeAccess cubeAccess){
  ArrayList filterAxesMemberList=null;
  Hierarchy[] noAccessHierarchies=cubeAccess.getNoAccessHierarchies();
  if (noAccessHierarchies != null) {
    for (int i=0; i < noAccessHierarchies.length; i++) {
      Walker walker=findHierarchy(noAccessHierarchies[i]);
      if (walker != null) {
        throw Util.getRes().newUserDoesNotHaveRightsTo(noAccessHierarchies[i].getUniqueName());
      }
    }
  }
  Member[] limitedMembers=cubeAccess.getLimitedMembers();
  if (limitedMembers != null) {
    for (int i=0; i < limitedMembers.length; i++) {
      Hierarchy limitedHierarchy=limitedMembers[i].getHierarchy();
      Member[] mdxMember={limitedMembers[i]};
      Walker walker=findHierarchy(limitedHierarchy);
      if (walker == null) {
        filterHierarchy(limitedHierarchy,slicerAxis,mdxMember);
      }
 else {
        int axis=getAxisCodeForWalker(walker);
        if (axis == slicerAxis) {
          Object foundNode=walker.currentElement();
          Member foundMember=null;
          if (foundNode instanceof Member) {
            foundMember=(Member)foundNode;
          }
 else           if (foundNode instanceof FunCall && ((FunCall)foundNode).isCallToTuple()) {
            FunCall funCall=(FunCall)foundNode;
            if (funCall.args[0] instanceof Member) {
              foundMember=(Member)funCall.args[0];
            }
          }
          if (foundMember != null) {
            applyLimitOnMember(foundMember,limitedMembers[i],axis);
          }
 else {
            moveHierarchy(limitedHierarchy,slicerAxis,noAxis,0,true);
            filterHierarchy(limitedHierarchy,slicerAxis,mdxMember);
          }
        }
 else         if (axis == xAxis || axis == yAxis) {
          if (walker.currentElement() instanceof Member) {
            applyLimitOnMember((Member)walker.currentElement(),limitedMembers[i],axis);
          }
 else {
            if (filterAxesMemberList == null) {
              filterAxesMemberList=new ArrayList();
            }
            filterAxesMemberList.add(limitedMembers[i]);
          }
        }
      }
    }
  }
  return filterAxesMemberList;
}

Fixed version (ground truth):
/** 
 * Apply   {@link CubeAccess} permissions to the query by filteringhierarchies, putting limits on the slicer, etc.  If some of the permissions can not be applied (user used expression like currentYear, which can not be computed prior to running query) the function returns array of limited members, which could not be applied. It means, that the we need to parse the results before showing them to the user.
 */
private ArrayList applyPermissions(CubeAccess cubeAccess){
  ArrayList filterAxesMemberList=null;
  Hierarchy[] noAccessHierarchies=cubeAccess.getNoAccessHierarchies();
  if (noAccessHierarchies != null) {
    for (int i=0; i < noAccessHierarchies.length; i++) {
      Walker walker=findHierarchy(noAccessHierarchies[i]);
      if (walker != null) {
        throw Util.getRes().newUserDoesNotHaveRightsTo(noAccessHierarchies[i].getUniqueName());
      }
    }
  }
  Member[] limitedMembers=cubeAccess.getLimitedMembers();
  if (limitedMembers != null) {
    for (int i=0; i < limitedMembers.length; i++) {
      Hierarchy limitedHierarchy=limitedMembers[i].getHierarchy();
      Member[] mdxMember={limitedMembers[i]};
      Walker walker=findHierarchy(limitedHierarchy);
      if (walker == null) {
        filterHierarchy(limitedHierarchy,slicerAxis,mdxMember);
      }
 else {
        int axis=getAxisCodeForWalker(walker);
        if (axis == slicerAxis) {
          Object foundNode=walker.currentElement();
          Member foundMember=null;
          if (foundNode instanceof Member) {
            foundMember=(Member)foundNode;
          }
 else           if (foundNode instanceof FunCall && ((FunCall)foundNode).isCallToTuple()) {
            FunCall funCall=(FunCall)foundNode;
            if (funCall.args[0] instanceof Member) {
              foundMember=(Member)funCall.args[0];
            }
          }
          if (foundMember != null) {
            applyLimitOnMember(foundMember,limitedMembers[i],axis);
          }
 else {
            moveHierarchy(limitedHierarchy,slicerAxis,noAxis,0,true);
            filterHierarchy(limitedHierarchy,slicerAxis,mdxMember);
          }
        }
 else         if (axis == xAxis || axis == yAxis) {
          if (walker.currentElement() instanceof Member) {
            applyLimitOnMember((Member)walker.currentElement(),limitedMembers[i],axis);
          }
 else {
            if (filterAxesMemberList == null) {
              filterAxesMemberList=new ArrayList();
            }
            filterAxesMemberList.add(limitedMembers[i]);
          }
        }
      }
    }
  }
  return filterAxesMemberList;
}