Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined behaviour problems in RecoTracker/TkHitPairs #27524

Merged
merged 4 commits into from Jul 20, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions RecoTracker/TkHitPairs/interface/LayerHitMapCache.h
Expand Up @@ -37,8 +37,13 @@ class LayerHitMapCache {
resize(other.theContainer.size());

for (size_t i = 0, size = other.theContainer.size(); i != size; ++i) {
assert(get(i) == nullptr); // We don't want to override any existing value
theContainer[i].reset(*(other.get(i))); // pass by reference to denote that we don't own it
assert(get(i) == nullptr); // We don't want to override any existing value
auto v = other.get(i); // pass by reference to denote that we don't own it
Dr15Jones marked this conversation as resolved.
Show resolved Hide resolved
if (v) {
theContainer[i].reset(*(other.get(i)));
} else {
theContainer[i].reset();
}
}
}
/// emptify cache, delete values associated to Key
Expand Down
2 changes: 2 additions & 0 deletions RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc
Expand Up @@ -152,6 +152,8 @@ void HitPairGeneratorFromLayerPair::doublets(const TrackingRegion& region,
for (int j = 0; j < 3; j += 2) {
auto b = innerRange[j];
auto e = innerRange[j + 1];
if (e == b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't if (e <= b) even safer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If b > e then the whole algorithm would be busted, wouldn't it?

continue;
bool ok[e - b];
switch (checkRZ->algo()) {
case (HitRZCompatibility::zAlgo):
Expand Down