BIND 10 trac2369, updated. ba71154440e841836726bbc6b9088f095d14f7d1 [2369] Fix vector::erase() call in InputSource
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Oct 31 07:20:52 UTC 2012
The branch, trac2369 has been updated
via ba71154440e841836726bbc6b9088f095d14f7d1 (commit)
from 51e26dc96b447d4f60b6aa2c428bfcfe6e6a4d04 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ba71154440e841836726bbc6b9088f095d14f7d1
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Oct 31 12:42:02 2012 +0530
[2369] Fix vector::erase() call in InputSource
The single-argument variant of vector::erase() deletes just one element
of the vector, not an entire range. Tests have been fixed to check
that the range from start to the current buffer position is dropped
correctly.
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/inputsource.cc | 2 +-
src/lib/dns/tests/inputsource_unittest.cc | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/inputsource.cc b/src/lib/dns/inputsource.cc
index b5b1e08..f52f493 100644
--- a/src/lib/dns/inputsource.cc
+++ b/src/lib/dns/inputsource.cc
@@ -107,7 +107,7 @@ InputSource::compact() {
if (buffer_pos_ == buffer_.size()) {
buffer_.clear();
} else {
- buffer_.erase(buffer_.begin() + buffer_pos_);
+ buffer_.erase(buffer_.begin(), buffer_.begin() + buffer_pos_);
}
buffer_pos_ = 0;
diff --git a/src/lib/dns/tests/inputsource_unittest.cc b/src/lib/dns/tests/inputsource_unittest.cc
index e2c386b..8c7ed4b 100644
--- a/src/lib/dns/tests/inputsource_unittest.cc
+++ b/src/lib/dns/tests/inputsource_unittest.cc
@@ -172,13 +172,18 @@ TEST_F(InputSourceTest, compactDuring) {
size_t line = source_.getCurrentLine();
EXPECT_EQ(2, line);
+ // Now, unget a couple of characters. This should cause the
+ // buffer_pos_ to be not equal to the size of the buffer.
+ source_.ungetChar();
+ source_.ungetChar();
+
source_.saveLine();
source_.compact();
// Ungetting here must throw.
EXPECT_THROW(source_.ungetChar(), InputSource::UngetError);
- for (size_t i = 15; i < str_length_; i++) {
+ for (size_t i = 13; i < str_length_; i++) {
EXPECT_EQ(str_[i], source_.getChar());
EXPECT_FALSE(source_.atEOF());
}
@@ -198,7 +203,7 @@ TEST_F(InputSourceTest, compactDuring) {
// Ungetting here must throw.
EXPECT_THROW(source_.ungetChar(), InputSource::UngetError);
- for (size_t i = 15; i < str_length_; i++) {
+ for (size_t i = 13; i < str_length_; i++) {
EXPECT_EQ(str_[i], source_.getChar());
EXPECT_FALSE(source_.atEOF());
}
More information about the bind10-changes
mailing list