Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Missed range check
Browse files Browse the repository at this point in the history
  • Loading branch information
EinarElen authored and tomeichlersmith committed Apr 18, 2024
1 parent 768160f commit 7912f2d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/SimCore/TrackMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@

namespace simcore {

void TrackMap::isDescendant(int trackID, int ancestorID,
bool TrackMap::isDescendant(int trackID, int ancestorID,
int maximum_depth) const {
int current_depth{0};
int current_track{trackID};
while (current_depth < maximum_depth) {
// Walk the tree until we either no longer have a parent or we reach the
// desired depth
while (current_depth < maximum_depth &&
(ancestry_.find(current_track) != ancestry_.end())) {
// See if we have encountered the parent of the current track
//
// operator[] is not const, so we need to use at()
current_track = ancestry_.at(current_track).first;
if (current_track == ancestorID) {
// If one of the parents is the track of interest, we are done!
return true;
}
current_depth++;
Expand Down

0 comments on commit 7912f2d

Please sign in to comment.