Fixed #2322 (cppcheck follows recursive symlinks)

This commit is contained in:
Daniel Marjamäki 2010-12-19 11:22:27 +01:00
parent 8247270f35
commit 1cd6f16ecf
1 changed files with 16 additions and 2 deletions

View File

@ -20,10 +20,12 @@
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#ifndef _WIN32 // POSIX-style system
#include <glob.h>
#include <unistd.h>
#include <stdlib.h> // canonicalize_file_name
#endif
#ifndef _WIN32
@ -53,8 +55,20 @@ void FileListerUnix::recursiveAddFiles(std::vector<std::string> &filenames, cons
if (filename[filename.length()-1] != '/')
{
// File
if (sameFileName(path,filename) || FileLister::acceptFile(filename))
filenames.push_back(filename);
char * const fname = canonicalize_file_name(filename.c_str());
if (!fname)
continue;
if (std::find(filenames.begin(), filenames.end(), std::string(fname)) != filenames.end())
{
free(fname);
continue;
}
if (sameFileName(path,fname) || FileLister::acceptFile(filename))
filenames.push_back(fname);
free(fname);
}
else
{