#vulnerable code 
                                private static List<String> listNames(File dir) {
        List<String> names = new ArrayList<String>();
        for (File file : dir.listFiles()) {
            String name = file.getName();
            if (name.startsWith(".") || file.isFile()) {
                continue;
            }
            names.add(name);
        }
        return names;
    } 
                            #location 3 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                                private static List<String> listNames(File dir) {
        List<String> names = new ArrayList<String>();
        if (!dir.exists()) {
            return names;
        }
        File[] files = dir.listFiles();
        if (files == null) {
            return names;
        }
        for (File file : files) {
            String name = file.getName();
            if (name.startsWith(".") || file.isFile()) {
                continue;
            }
            names.add(name);
        }
        return names;
    }