From 1cd6f16ecf7364241f1c3103d9286815e8f7fdb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 19 Dec 2010 11:22:27 +0100 Subject: [PATCH] Fixed #2322 (cppcheck follows recursive symlinks) --- lib/filelister_unix.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/filelister_unix.cpp b/lib/filelister_unix.cpp index 472d2149a..4bdcfd730 100644 --- a/lib/filelister_unix.cpp +++ b/lib/filelister_unix.cpp @@ -20,10 +20,12 @@ #include #include #include +#include #ifndef _WIN32 // POSIX-style system #include #include +#include // canonicalize_file_name #endif #ifndef _WIN32 @@ -53,8 +55,20 @@ void FileListerUnix::recursiveAddFiles(std::vector &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 {