050-Bugfix-erase-on-derived-__base_associative.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From 946b29e62927eadfc4e87f27b8d30e5974b78c4c Mon Sep 17 00:00:00 2001
  2. From: Ben Kelly <ben@benjii.net>
  3. Date: Mon, 6 Feb 2017 13:08:25 +0200
  4. Subject: [PATCH] Bugfix erase() on derived __base_associative
  5. When calling erase() on a containers derived from __base_associative
  6. (e.g. multimap) and providing a pair of iterators a segfault will
  7. occur.
  8. Example code to reproduce:
  9. typedef std::multimap<int, int> testmap;
  10. testmap t;
  11. t.insert(std::pair<int, int>(1, 1));
  12. t.insert(std::pair<int, int>(2, 1));
  13. t.insert(std::pair<int, int>(3, 1));
  14. t.erase(t.begin(), t.end());
  15. Signed-off-by: Ben Kelly <ben@benjii.net>
  16. ---
  17. include/associative_base | 3 +--
  18. 1 file changed, 1 insertion(+), 2 deletions(-)
  19. diff --git a/include/associative_base b/include/associative_base
  20. index 27ae0ef..be8b27f 100644
  21. --- a/include/associative_base
  22. +++ b/include/associative_base
  23. @@ -200,8 +200,7 @@ public:
  24. }
  25. void erase(iterator first, iterator last){
  26. while(first != last){
  27. - backing.erase(first.base_iterator());
  28. - ++first;
  29. + first = backing.erase(first.base_iterator());
  30. }
  31. }
  32. --
  33. 2.7.4