From: Arvin Schnell Date: Thu, 29 Sep 2011 09:31:14 +0000 (+0200) Subject: - check iterator in findPre X-Git-Tag: v0.1.3~278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a3111fb62e7302f55af0b53fcc80ca0254b1efe;p=thirdparty%2Fsnapper.git - check iterator in findPre --- diff --git a/snapper/Snapshot.cc b/snapper/Snapshot.cc index 85af4b4d..2578fb43 100644 --- a/snapper/Snapshot.cc +++ b/snapper/Snapshot.cc @@ -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() { diff --git a/snapper/Snapshot.h b/snapper/Snapshot.h index 8e083fd8..7d2e1250 100644 --- a/snapper/Snapshot.h +++ b/snapper/Snapshot.h @@ -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;