This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 773108b  Fix #5094: Fix use after free in test_IntrusiveHashMap.cc
773108b is described below

commit 773108b0469770691a750e4ed42b7b66cd41678a
Author: Alan M. Carroll <a...@apache.org>
AuthorDate: Mon Mar 4 15:37:43 2019 -0600

    Fix #5094: Fix use after free in test_IntrusiveHashMap.cc
---
 src/tscore/unit_tests/test_IntrusiveHashMap.cc | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/tscore/unit_tests/test_IntrusiveHashMap.cc 
b/src/tscore/unit_tests/test_IntrusiveHashMap.cc
index a0521a2..5e615c0 100644
--- a/src/tscore/unit_tests/test_IntrusiveHashMap.cc
+++ b/src/tscore/unit_tests/test_IntrusiveHashMap.cc
@@ -90,9 +90,10 @@ TEST_CASE("IntrusiveHashMap", "[libts][IntrusiveHashMap]")
   map.insert(new Thing("dave"));
   map.insert(new Thing("persia"));
   REQUIRE(map.count() == 3);
-  for (auto &thing : map) {
-    delete &thing;
-  }
+  // Need to be bit careful cleaning up, since the link pointers are in the 
objects and deleting
+  // the object makes it unsafe to use an iterator referencing that object. 
For a full cleanup,
+  // the best option is to first delete everything, then clean up the map.
+  map.apply([](Thing *thing) { delete thing; });
   map.clear();
   REQUIRE(map.count() == 0);
 

Reply via email to