Skip to content

Commit 1564fd7

Browse files
committed
Fixed potential out of bounds access
1 parent 96ef435 commit 1564fd7

File tree

1 file changed

+2
-4
lines changed
  • RecoTracker/LSTCore/src/alpaka

1 file changed

+2
-4
lines changed

RecoTracker/LSTCore/src/alpaka/Hit.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,16 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE::lst {
6262
alpaka::math::acosh(
6363
acc, alpaka::math::sqrt(acc, ihit_x * ihit_x + ihit_y * ihit_y + ihit_z * ihit_z) / hits.rts()[ihit]);
6464
auto found_pointer = alpaka_std::lower_bound(modules.mapdetId(), modules.mapdetId() + nModules, iDetId);
65+
ALPAKA_ASSERT_ACC(found_pointer != modules.mapdetId() + nModules);
6566
int found_index = std::distance(modules.mapdetId(), found_pointer);
66-
if (found_pointer == modules.mapdetId() + nModules)
67-
found_index = -1;
6867
uint16_t lastModuleIndex = modules.mapIdx()[found_index];
6968

7069
hits.moduleIndices()[ihit] = lastModuleIndex;
7170

7271
if (modules.subdets()[lastModuleIndex] == Endcap && modules.moduleType()[lastModuleIndex] == TwoS) {
7372
found_pointer = alpaka_std::lower_bound(geoMapDetId, geoMapDetId + nEndCapMap, iDetId);
73+
ALPAKA_ASSERT_ACC(found_pointer != geoMapDetId + nEndCapMap);
7474
found_index = std::distance(geoMapDetId, found_pointer);
75-
if (found_pointer == geoMapDetId + nEndCapMap)
76-
found_index = -1;
7775
float phi = geoMapPhi[found_index];
7876
float cos_phi = alpaka::math::cos(acc, phi);
7977
hits.highEdgeXs()[ihit] = ihit_x + 2.5f * cos_phi;

0 commit comments

Comments
 (0)