#vulnerable code 
                                Token[] expand(Token[] array, int index) {
        if (index < array.length && infoMap.containsKey(array[index].value)) {
            // if we hit a token whose info.cppText starts with #define (a macro), expand it
            int startIndex = index;
            Info info = infoMap.getFirst(array[index].value);
            if (info != null && info.cppText != null) {
                try {
                    Tokenizer tokenizer = new Tokenizer(info.cppText, array[index].file, array[index].lineNumber);
                    if (!tokenizer.nextToken().match('#')
                            || !tokenizer.nextToken().match(Token.DEFINE)
                            || !tokenizer.nextToken().match(info.cppNames[0])) {
                        return array;
                    }
                    // copy the array of tokens up to this point
                    List<Token> tokens = new ArrayList<Token>();
                    for (int i = 0; i < index; i++) {
                        tokens.add(array[i]);
                    }
                    List<String> params = new ArrayList<String>();
                    List<Token>[] args = null;
                    Token token = tokenizer.nextToken();
                    if (info.cppNames[0].equals("__COUNTER__")) {
                        token.value = Integer.toString(counter++);
                    }
                    // pick up the parameters and arguments of the macro if it has any
                    String name = array[index].value;
                    if (token.match('(')) {
                        token = tokenizer.nextToken();
                        while (!token.isEmpty()) {
                            if (token.match(Token.IDENTIFIER)) {
                                params.add(token.value);
                            } else if (token.match(')')) {
                                token = tokenizer.nextToken();
                                break;
                            }
                            token = tokenizer.nextToken();
                        }
                        index++;
                        if (params.size() > 0 && (index >= array.length || !array[index].match('('))) {
                            return array;
                        }
                        name += array[index].spacing + array[index];
                        args = new List[params.size()];
                        int count = 0, count2 = 0;
                        for (index++; index < array.length; index++) {
                            Token token2 = array[index];
                            name += token2.spacing + token2;
                            if (count2 == 0 && token2.match(')')) {
                                break;
                            } else if (count2 == 0 && token2.match(',')) {
                                count++;
                                continue;
                            } else if (token2.match('(','[','{')) {
                                count2++;
                            } else if (token2.match(')',']','}')) {
                                count2--;
                            }
                            if (count < args.length) {
                                if (args[count] == null) {
                                    args[count] = new ArrayList<Token>();
                                }
                                args[count].add(token2);
                            }
                        }
                        // expand the arguments of the macros as well
                        for (int i = 0; i < args.length; i++) {
                            if (infoMap.containsKey(args[i].get(0).value)) {
                                args[i] = Arrays.asList(expand(args[i].toArray(new Token[args[i].size()]), 0));
                            }
                        }
                    }
                    int startToken = tokens.size();
                    // expand the token in question, unless we should skip it
                    info = infoMap.getFirst(name);
                    while ((info == null || !info.skip) && !token.isEmpty()) {
                        boolean foundArg = false;
                        for (int i = 0; i < params.size(); i++) {
                            if (params.get(i).equals(token.value)) {
                                String s = token.spacing;
                                for (Token arg : args[i]) {
                                    // clone tokens here to avoid potential problems with concatenation below
                                    Token t = new Token(arg);
                                    if (s != null) {
                                        t.spacing += s;
                                    }
                                    tokens.add(t);
                                    s = null;
                                }
                                foundArg = true;
                                break;
                            }
                        }
                        if (!foundArg) {
                            if (token.type == -1) {
                                token.type = Token.COMMENT;
                            }
                            tokens.add(token);
                        }
                        token = tokenizer.nextToken();
                    }
                    // concatenate tokens as required
                    for (int i = startToken; i < tokens.size(); i++) {
                        if (tokens.get(i).match("##") && i > 0 && i + 1 < tokens.size()) {
                            tokens.get(i - 1).value += tokens.get(i + 1).value;
                            tokens.remove(i);
                            tokens.remove(i);
                            i--;
                        }
                    }
                    // copy the rest of the tokens from this point on
                    for (index++; index < array.length; index++) {
                        tokens.add(array[index]);
                    }
                    if ((info == null || !info.skip) && startToken < tokens.size()) {
                        tokens.get(startToken).spacing = array[startIndex].spacing;
                    }
                    array = tokens.toArray(new Token[tokens.size()]);
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
            }
        }
        return array;
    } 
                            #location 10 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                TokenIndexer(InfoMap infoMap, Token[] array, boolean isCFile) {
        this.infoMap = infoMap;
        this.array = array;
        this.isCFile = isCFile;
    }