From 250de83bf2c13e612c8ecbd6ac38a54d3d4de6fb Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 25 Nov 2021 16:23:16 -0500 Subject: [PATCH] Prevent divide-by-zero in DIALOG_PCM_PROGRESS --- kicad/pcm/dialogs/dialog_pcm_progress.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kicad/pcm/dialogs/dialog_pcm_progress.cpp b/kicad/pcm/dialogs/dialog_pcm_progress.cpp index 02c82d1e77..bbe1d4c0cc 100644 --- a/kicad/pcm/dialogs/dialog_pcm_progress.cpp +++ b/kicad/pcm/dialogs/dialog_pcm_progress.cpp @@ -110,9 +110,11 @@ void DIALOG_PCM_PROGRESS::SetFinished() bool DIALOG_PCM_PROGRESS::updateUI() { bool finished = m_finished.load(); - int phase = m_phase.load(); - int phases = m_numPhases.load(); - double current = m_currentProgress.load() / (double) m_currentProgressTotal.load(); + int phase = m_phase.load(); + int phases = m_numPhases.load(); + long cp = m_currentProgress.load(); + long total = m_currentProgressTotal.load(); + double current = ( total > 0 ) ? ( double( cp ) / double( total ) ) : 0; if( phases > 0 ) current = ( phase + current ) / phases;