diff --git a/CHANGELOG.md b/CHANGELOG.md index 22607f71..6018181e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version XXX: + +* fix erase field + +-------------------------------------------------------------------------------- + Version 284: * fix compilation macro documentation diff --git a/include/boost/beast/http/impl/fields.hpp b/include/boost/beast/http/impl/fields.hpp index 2711df38..f3d609e8 100644 --- a/include/boost/beast/http/impl/fields.hpp +++ b/include/boost/beast/http/impl/fields.hpp @@ -617,7 +617,7 @@ erase(const_iterator pos) -> { auto next = pos; auto& e = *next++; - set_.erase(e); + set_.erase(set_.iterator_to(e)); list_.erase(pos); delete_element(const_cast(e)); return next; diff --git a/test/beast/http/fields.cpp b/test/beast/http/fields.cpp index 92c1d5e5..7ddb9d44 100644 --- a/test/beast/http/fields.cpp +++ b/test/beast/http/fields.cpp @@ -988,6 +988,21 @@ public: BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo"); } + void + testIssue1828() + { + beast::http::fields req; + req.insert("abc", "1"); + req.insert("abc", "2"); + req.insert("abc", "3"); + BEAST_EXPECT(req.count("abc") == 3); + auto iter = req.find("abc"); + BEAST_EXPECT(iter->value() == "1"); + req.insert("abc", "4"); + req.erase(iter); + BEAST_EXPECT(req.count("abc") == 3); + } + void run() override { @@ -1002,6 +1017,8 @@ public: testKeepAlive(); testContentLength(); testChunked(); + + testIssue1828(); } };