• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision23125 (tree)
Zeit2012-08-03 19:12:43
Autorstefan.fuhrmann.1974

Log Message

When removing log caches back-to-front, we may remove more
than one entry at a time (i.e. if root + UUID match multiple
entries). Instead of using iterators, we must use verifiable
direct indexes.

(Fixes issue #384) : Crash when removing old log caches

Ändern Zusammenfassung

Diff

--- trunk/src/LogCache/LogCachePool.cpp (revision 23124)
+++ trunk/src/LogCache/LogCachePool.cpp (revision 23125)
@@ -156,13 +156,18 @@
156156 // update cache info list and also remove entries
157157 // that don't have a cache file anymore
158158
159- for ( const CRepositoryInfo::SPerRepositoryInfo* const * iter
160- = repositoryInfo->data.end()
161- , * const *end = repositoryInfo->data.begin()
162- ; iter != end
163- ; --iter)
159+ for (size_t i = repositoryInfo->data.size(); i > 0; --i)
164160 {
165- const CRepositoryInfo::SPerRepositoryInfo* info = *(iter-1);
161+ // DropEntry may remove more than one entry per call
162+
163+ if (i > repositoryInfo->data.size())
164+ continue;
165+
166+ // entry still exists. Check whether we have to remove it
167+
168+ const CRepositoryInfo::SPerRepositoryInfo* info
169+ = repositoryInfo->data[i-1];
170+
166171 if ( (deletedCaches.find (info->fileName) != deletedCaches.end())
167172 || (allFiles.find (info->fileName) == allFiles.end()))
168173 {
@@ -289,13 +294,11 @@
289294 {
290295 std::multimap<CString, CString> result;
291296
292- for ( const CRepositoryInfo::SPerRepositoryInfo* const * iter
293- = repositoryInfo->data.begin()
294- , * const *end = repositoryInfo->data.end()
295- ; iter != end
296- ; ++iter)
297+ for (size_t i = 0, count = repositoryInfo->data.size(); i != count; ++i)
297298 {
298- const CRepositoryInfo::SPerRepositoryInfo* info = *iter;
299+ const CRepositoryInfo::SPerRepositoryInfo* info
300+ = repositoryInfo->data[i];
301+
299302 result.insert (std::make_pair (info->root, info->uuid));
300303 }
301304
--- trunk/src/LogCache/RepositoryInfo.cpp (revision 23124)
+++ trunk/src/LogCache/RepositoryInfo.cpp (revision 23125)
@@ -367,16 +367,15 @@
367367
368368 // data access
369369
370-const CRepositoryInfo::SPerRepositoryInfo* const *
371-CRepositoryInfo::CData::begin() const
370+size_t CRepositoryInfo::CData::size() const
372371 {
373- return data.empty() ? NULL : &data.front();
372+ return data.size();
374373 }
375374
376-const CRepositoryInfo::SPerRepositoryInfo* const *
377-CRepositoryInfo::CData::end() const
375+const CRepositoryInfo::SPerRepositoryInfo*
376+CRepositoryInfo::CData::operator[](size_t index) const
378377 {
379- return begin() + data.size();
378+ return data[index];
380379 }
381380
382381 // share the repository info pool thoughout this application
--- trunk/src/LogCache/RepositoryInfo.h (revision 23124)
+++ trunk/src/LogCache/RepositoryInfo.h (revision 23125)
@@ -170,8 +170,8 @@
170170
171171 /// data access
172172
173- const SPerRepositoryInfo* const * begin() const;
174- const SPerRepositoryInfo* const * end() const;
173+ size_t size() const;
174+ const SPerRepositoryInfo* operator[](size_t index) const;
175175 };
176176
177177 /// cached repository properties
Show on old repository browser