mirror of
https://github.com/miek/inspectrum.git
synced 2026-03-20 07:07:11 +01:00
traceplot: Fix divide by zero crash
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 <johannes.demel@dedrone.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user