#vulnerable code 
                              @Override
  public FTNode next(final XPContext ctx) {
    final FTPositionFilter tmp = ctx.ftpos;
    ctx.ftpos = ftpos;
    
    final FTNode n1 = calcFTAnd(pex, ctx);
    
/*    nod2 = (nex.length > 0 && nod2 == null && more(nex)) ? 
        calcFTAnd(nex, ctx) : nod2;
*/
    if (n1 != null) {
      nod2 = (nex.length > 0 && nod2 == null && more(nex)) ? 
          calcFTAnd(nex, ctx) : nod2;
      if (nod2 != null) {
        int d = n1.getPre() - nod2.getPre();
        while (d > 0) {
          if (!more(nex)) break;
          nod2 = calcFTAnd(nex, ctx);
          if (nod2.size > 0) {
            d = n1.getPre() - nod2.getPre();
          } else {
            break;
          }
        }
        if (d != 0) return n1;
        else {
          if (more()) {
            nod2 = null;
            return next(ctx);
          } else return new FTNode();
        }
      }
      ctx.ftpos = tmp;
      return n1;
    }
    final FTNode n2 = calcFTAnd(nex, ctx);  
    ctx.ftpos = tmp;
    return n2;
  } 
                            #location 19 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                              @Override
  public FTNode next(final XPContext ctx) {
    final FTPositionFilter tmp = ctx.ftpos;
    ctx.ftpos = ftpos;
    
    final FTNode n1 = calcFTAnd(pex, ctx);

    if (n1 != null && n1.size > 0) {
      nod2 = (nex.length > 0 && nod2 == null && more(nex)) ? 
          calcFTAnd(nex, ctx) : nod2;
      if (nod2 != null) {
        int d = n1.getPre() - nod2.getPre();
        while (d > 0) {
          if (!more(nex)) break;
          nod2 = calcFTAnd(nex, ctx);
          if (nod2.size > 0) {
            d = n1.getPre() - nod2.getPre();
          } else {
            break;
          }
        }
        if (d != 0) return n1;
        else {
          if (more()) {
            nod2 = null;
            return next(ctx);
          } else return new FTNode();
        }
      }
      ctx.ftpos = tmp;
      return n1;
    }
    final FTNode n2 = calcFTAnd(nex, ctx);  
    ctx.ftpos = tmp;
    return n2;
  }