Skip to content

Commit

Permalink
traceplot: Fix divide by zero crash
Browse files Browse the repository at this point in the history
Very small files would cause inspectrum to crash with a SIGFPE. In the
end, this is caused by input that let's `samplesPerColumn == 0`. Make
sure this value is at least `1` and it doesn't crash anymore.

Signed-off-by: Johannes Demel <[email protected]>
  • Loading branch information
jdemel committed Jul 30, 2024
1 parent 6a1ee5a commit 7830cde
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/traceplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void TracePlot::paintMid(QPainter &painter, QRect &rect, range_t<size_t> sampleR
{
if (sampleRange.length() == 0) return;

int samplesPerColumn = sampleRange.length() / rect.width();
int samplesPerColumn = std::max(1UL, sampleRange.length() / rect.width());
int samplesPerTile = tileWidth * samplesPerColumn;
size_t tileID = sampleRange.minimum / samplesPerTile;
size_t tileOffset = sampleRange.minimum % samplesPerTile; // Number of samples to skip from first image tile
Expand Down

0 comments on commit 7830cde

Please sign in to comment.