# HG changeset patch # User Peter Kovacs # Date 2009-12-13 22:19:08 # Node ID 4db8d5ccd26bfffa41fe796e55216b3baf4e1d33 # Parent 9cc6e98c487d3a14fe1db17001f3c4a47350dc80 Memory leak bugfix in BellmanFord (#51) diff --git a/lemon/bellman_ford.h b/lemon/bellman_ford.h --- a/lemon/bellman_ford.h +++ b/lemon/bellman_ford.h @@ -237,7 +237,9 @@ _local_dist = true; _dist = Traits::createDistMap(*_gr); } - _mask = new MaskMap(*_gr, false); + if(!_mask) { + _mask = new MaskMap(*_gr); + } } public : @@ -404,6 +406,10 @@ _process.push_back(it); _mask->set(it, true); } + } else { + for (NodeIt it(*_gr); it != INVALID; ++it) { + _mask->set(it, false); + } } }