From 3ae5c0df1801bc0d446eee18915544c272b2309a Mon Sep 17 00:00:00 2001 From: Adam Wardynski <award@.(win7-laptop)> Date: Thu, 21 Apr 2011 21:06:25 +0200 Subject: [PATCH] Fix out-of-range condition for submatch. --- libwccl/values/matchvector.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libwccl/values/matchvector.cpp b/libwccl/values/matchvector.cpp index 24b77b8..bf80136 100644 --- a/libwccl/values/matchvector.cpp +++ b/libwccl/values/matchvector.cpp @@ -90,19 +90,19 @@ void MatchVector::append(const boost::shared_ptr<MatchData> &m) } const boost::shared_ptr<const Match> MatchVector::submatch(size_t idx) const { - if (idx + 1< matches_.size() || idx == 0) { + if ((idx < matches_.size() + 1) || (idx == 0)) { return matches_[idx - 1]; } else { - throw Wccl::WcclError("Match vector index out of range"); + throw Wccl::WcclError("Match vector index out of range."); } } const boost::shared_ptr<Match>& MatchVector::submatch(size_t idx) { - if (idx + 1 < matches_.size() || idx == 0) { + if ((idx < matches_.size() + 1) || (idx == 0)) { return matches_[idx - 1]; } else { - throw Wccl::WcclError("Match vector index out of range"); + throw Wccl::WcclError("Match vector index out of range."); } } -- GitLab