Skip to content

Commit

Permalink
Merge pull request #2544 from cta-observatory/fix_flashcam_extractor
Browse files Browse the repository at this point in the history
Fix possible out of bounds error in FlashCamExtractor
  • Loading branch information
maxnoe committed Apr 25, 2024
2 parents d3121f7 + dba9d7d commit 8b6df5c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changes/2544.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a possible out-of-bounds array access in the FlashCamExtractor.
4 changes: 2 additions & 2 deletions src/ctapipe/image/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,15 +1531,15 @@ def adaptive_centroid(waveforms, peak_index, rel_descend_limit, centroids):
sum_ += waveforms[j]
jsum += j * waveforms[j]
j -= 1
if waveforms[j] > peak_amplitude:
if j >= 0 and waveforms[j] > peak_amplitude:
descend_limit = rel_descend_limit * peak_amplitude

j = peak_index + 1
while j < n_samples and waveforms[j] > descend_limit:
sum_ += waveforms[j]
jsum += j * waveforms[j]
j += 1
if waveforms[j] > peak_amplitude:
if j < n_samples and waveforms[j] > peak_amplitude:
descend_limit = rel_descend_limit * peak_amplitude

if sum_ != 0.0:
Expand Down

0 comments on commit 8b6df5c

Please sign in to comment.