From feb8a03d5f2893281a34026b7eccbe891d18a909 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 21 Aug 2014 11:25:07 +0100 Subject: [PATCH] [btree_damage_tracker] Initialise all path_tracker objects with a null path. This fixes an insidious bug that took me ages to track down. Without it the non-existent front() of a list was sometimes being accessed. --- persistent-data/data-structures/btree_damage_visitor.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/persistent-data/data-structures/btree_damage_visitor.h b/persistent-data/data-structures/btree_damage_visitor.h index 7886d85..1eede99 100644 --- a/persistent-data/data-structures/btree_damage_visitor.h +++ b/persistent-data/data-structures/btree_damage_visitor.h @@ -85,12 +85,17 @@ namespace persistent_data { // different sub tree (by looking at the btree_path). class path_tracker { public: + path_tracker() { + // We push an empty path, to ensure there + // is always a current_path. + paths_.push_back(btree_path()); + } + // returns the old path if the tree has changed. btree_path const *next_path(btree_path const &p) { if (p != current_path()) { if (paths_.size() == 2) paths_.pop_front(); - paths_.push_back(p); return &paths_.front();