From 6d9eec0e710e47a62fc77b9c828444e722a7ba22 Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Fri, 26 May 2017 21:47:51 +0200 Subject: [PATCH] Fix crash in download piece bar When torrent size is smaller than the image width, bytes per pixel was set to zero and code was crashing. Set it to -1 instead, as we do when image is empty. This will disable highliting, but our algorithm does not work in this case anyway. --- src/gui/properties/piecesbar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/properties/piecesbar.cpp b/src/gui/properties/piecesbar.cpp index d34fdca2b..f495f82c1 100644 --- a/src/gui/properties/piecesbar.cpp +++ b/src/gui/properties/piecesbar.cpp @@ -50,7 +50,8 @@ namespace { public: PieceIndexToImagePos(const BitTorrent::TorrentInfo &torrentInfo, const QImage &image) - : m_bytesPerPixel {image.width() > 0 ? torrentInfo.totalSize() / image.width() : -1} + : m_bytesPerPixel {(image.width() > 0 && torrentInfo.totalSize() >= image.width()) + ? torrentInfo.totalSize() / image.width() : -1} , m_torrentInfo {torrentInfo} { if ((m_bytesPerPixel > 0) && (m_bytesPerPixel < 10))