From cc75e1a2a17cbbbc92ab0ec87ad40b55f966aff2 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 18 Aug 2016 19:54:07 +0800 Subject: [PATCH] mon/PGMonitor: fix potential underflow h.h.size() could be 0(theoretically), so "h.h.size() - 1" could underflow. Signed-off-by: xie xingguo --- src/mon/PGMonitor.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index d07f5110df8..b6c797d1649 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; -- 2.39.5