In void FastGraph::on_pbAutoLevel_clicked() is a potential floating 0
divide.  The computation of m_ave = sum/fast_jh can, if fast_jh is 0, yield
Inf if sum !=0 or NaN if sum == 0. That value is later converted to an int,
which is undefined.  The resulting int is likely to overflow the integer
computation of the argument given to SetValue.

diff --git a/widgets/fastgraph.cpp b/widgets/fastgraph.cpp
index 9efe5fc63..10580f82a 100644
--- a/widgets/fastgraph.cpp
+++ b/widgets/fastgraph.cpp
@@ -98,7 +98,11 @@ void FastGraph::on_pbAutoLevel_clicked()
   for(int i=0; i<=fast_jh; i++) {
     sum += fast_green[i];
   }
-  m_ave=sum/fast_jh;
+  if (fast_jh == 0) {
+    m_ave=0.0;
+  } else {
+    m_ave=sum/fast_jh;
+  }
   ui->gainSlider->setValue(127-int(2.2*m_ave));
   ui->zeroSlider->setValue(int(m_ave)+20);
   ui->greenZeroSlider->setValue(160-int(3.3*m_ave));
_______________________________________________
wsjt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wsjt-devel

Reply via email to