From: xie xingguo Date: Thu, 18 Aug 2016 11:54:07 +0000 (+0800) Subject: mon/PGMonitor: fix potential underflow X-Git-Tag: v11.0.1~422^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cc75e1a2a17cbbbc92ab0ec87ad40b55f966aff2;p=ceph.git mon/PGMonitor: fix potential underflow h.h.size() could be 0(theoretically), so "h.h.size() - 1" could underflow. Signed-off-by: xie xingguo --- diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index d07f5110df88..b6c797d1649c 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -2077,6 +2077,9 @@ int PGMonitor::_warn_slow_request_histogram(const pow2_hist_t& h, string suffix, list >& summary, list > *detail) const { + if (h.h.empty()) + return 0; + unsigned sum = 0; for (unsigned i = h.h.size() - 1; i > 0; --i) { float ub = (float)(1 << i) / 1000.0;