[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    A simple patch for strigi
From:       Jaime Torres <jtamate () gmail ! com>
Date:       2009-10-27 19:30:18
Message-ID: 200910272030.19552.jtamate () gmail ! com
[Download RAW message or body]


Hi,

  As I'm not able to use reviewboard today, I'll ask here:

The first part is to avoid a DIR leak.
The second part is to avoid to use the same variable name into two nested 
loops. gcc may work perfectly fine with it, but probably other compilers 
(will) not.

--- strigi/src/luceneindexer/luceneindexer.cpp	(revision 1041313)
+++ strigi/src/luceneindexer/luceneindexer.cpp	(copia de trabajo)
@@ -46,6 +46,7 @@ checkIndexdirIsEmpty(const char* dir) {
     while (de) {
         if (strcmp(de->d_name, "..") && strcmp(de->d_name, ".")) {
             fprintf(stderr, "Directory %s is not empty.\n", dir);
+            closedir(d);
             return false;
         }
         de = readdir(d);
--- strigi/src/daemon/eventlistener/fslistener.cpp	(revision 1041313)
+++ strigi/src/daemon/eventlistener/fslistener.cpp	(copia de trabajo)
@@ -388,14 +388,14 @@ void FsListener::reindex()
     
     calculateDiff(m_indexedDirs, reindexDirs, dirsDeleted, dirsCreated);
 
-    for (set<string>::iterator iter = dirsCreated.begin();
-         iter != dirsCreated.end() && !reindexReq(); ++iter)
+    for (set<string>::iterator iter1 = dirsCreated.begin();
+         iter1 != dirsCreated.end() && !reindexReq(); ++iter1)
     {
         DirLister lister(m_pAnalyzerConfiguration);
         string path;
         vector<pair<string, struct stat> > dirs;
 
-        lister.startListing (*iter);
+        lister.startListing (*iter1);
         int ret = lister.nextDir(path, dirs);
 
         while (ret != -1) {

// The rest of the affected loop:
            vector<pair<string, struct stat> >::iterator iter;
            for (iter = dirs.begin(); iter != dirs.end(); iter++) {
                struct stat stats = iter->second;
                if (S_ISDIR(stats.st_mode)) {//dir
                    set<string> toWatch;
                    recursivelyMonitor (iter->first, toWatch, events);
                    // add new watches
                    addWatches (toWatch);
                    dirsMonitored.insert (iter->first);
                }
                else if (S_ISREG(stats.st_mode)) {
                    //file
                    events.push_back (new Event (Event::CREATED, iter-
>first));
                }
            }
            ret = lister.nextDir(path, dirs);


["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic