]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMonitor: fix potential underflow 10739/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Thu, 18 Aug 2016 11:54:07 +0000 (19:54 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Thu, 18 Aug 2016 11:58:26 +0000 (19:58 +0800)
h.h.size() could be 0(theoretically), so "h.h.size() - 1" could underflow.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/mon/PGMonitor.cc

index d07f5110df8829390b72b313322d91a1596e4708..b6c797d1649c9fe3e79cbe81680f0535c2481f75 100644 (file)
@@ -2077,6 +2077,9 @@ int PGMonitor::_warn_slow_request_histogram(const pow2_hist_t& h, string suffix,
                                             list<pair<health_status_t,string> >& summary,
                                             list<pair<health_status_t,string> > *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;