summaryrefslogtreecommitdiff
path: root/ui/qt/qcustomplot.cpp
diff options
context:
space:
mode:
authorAlexis La Goutte <alexis.lagoutte@gmail.com>2015-05-13 08:02:58 +0200
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2015-05-13 17:38:04 +0000
commita3666e5e399f83b609413a6d0d382bc15ae92e70 (patch)
tree761df223063646f2a397cb7d1e3b14d777059ad5 /ui/qt/qcustomplot.cpp
parent4c4328e3167bf91f63da56ca919b3b9e3a12981a (diff)
downloadwireshark-a3666e5e399f83b609413a6d0d382bc15ae92e70.tar.gz
QCustomPlot: fix division(or modulo) by zero found by Clang and Coverity (CID 1159170 & 1159171)
Try 2 Change-Id: I10c439ccd4b8e5ac24275332e35fb35ad95b8d1b Reviewed-on: https://code.wireshark.org/review/8447 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'ui/qt/qcustomplot.cpp')
-rw-r--r--ui/qt/qcustomplot.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/ui/qt/qcustomplot.cpp b/ui/qt/qcustomplot.cpp
index 1573f02920..eab739aa29 100644
--- a/ui/qt/qcustomplot.cpp
+++ b/ui/qt/qcustomplot.cpp
@@ -2845,8 +2845,9 @@ int QCPLayoutGrid::elementCount() const
/* inherits documentation from base class */
QCPLayoutElement *QCPLayoutGrid::elementAt(int index) const
{
- if (index >= 0 && index < elementCount())
- return mElements.at(index / columnCount()).at(index % columnCount());
+ int colC = columnCount();
+ if (index >= 0 && colC && index < elementCount())
+ return mElements.at(index / colC).at(index % colC);
else
return 0;
}
@@ -2854,10 +2855,16 @@ QCPLayoutElement *QCPLayoutGrid::elementAt(int index) const
/* inherits documentation from base class */
QCPLayoutElement *QCPLayoutGrid::takeAt(int index)
{
+
+ int colC = columnCount();
+ if(colC == 0)
+ return 0;
+
if (QCPLayoutElement *el = elementAt(index))
{
+
releaseElement(el);
- mElements[index / columnCount()][index % columnCount()] = 0;
+ mElements[index / colC][index % colC] = 0;
return el;
} else
{