]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- check iterator in findPre
authorArvin Schnell <aschnell@suse.de>
Thu, 29 Sep 2011 09:31:14 +0000 (11:31 +0200)
committerArvin Schnell <aschnell@suse.de>
Thu, 29 Sep 2011 09:31:14 +0000 (11:31 +0200)
snapper/Snapshot.cc
snapper/Snapshot.h

index 85af4b4d98d64325ca73fa734dd89539003a2381..2578fb431c885c233b7e1d0a57f20aa2126fca81 100644 (file)
@@ -314,6 +314,26 @@ namespace snapper
     }
 
 
+    Snapshots::iterator
+    Snapshots::findPre(const_iterator post)
+    {
+       if (post == entries.end() || post->isCurrent() || post->getType() != POST)
+           throw IllegalSnapshotException();
+
+       return find(post->pre_num);
+    }
+
+
+    Snapshots::const_iterator
+    Snapshots::findPre(const_iterator post) const
+    {
+       if (post == entries.end() || post->isCurrent() || post->getType() != POST)
+           throw IllegalSnapshotException();
+
+       return find(post->pre_num);
+    }
+
+
     unsigned int
     Snapshots::nextNumber()
     {
index 8e083fd8764fbbd4173508ab8486b870482854a5..7d2e12502e27eb3e899ad40859a6df16957aeef3 100644 (file)
@@ -172,8 +172,8 @@ namespace snapper
        iterator find(unsigned int num);
        const_iterator find(unsigned int num) const;
 
-       iterator findPre(const_iterator pre) { return find(pre->pre_num); }
-       const_iterator findPre(const_iterator pre) const { return find(pre->pre_num); }
+       iterator findPre(const_iterator post);
+       const_iterator findPre(const_iterator post) const;
 
        iterator findPost(const_iterator pre);
        const_iterator findPost(const_iterator pre) const;