From: bert hubert Date: Wed, 17 Aug 2016 09:12:55 +0000 (+0200) Subject: malloctrace would crash if you asked it for more topAllocators than there were X-Git-Tag: rec-4.0.2~25 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fa69203a49eb0d51913e23de656960d1c390e55;p=thirdparty%2Fpdns.git malloctrace would crash if you asked it for more topAllocators than there were --- diff --git a/pdns/malloctrace.cc b/pdns/malloctrace.cc index 750782c78a..e58add9b62 100644 --- a/pdns/malloctrace.cc +++ b/pdns/malloctrace.cc @@ -90,7 +90,9 @@ MallocTracer::allocators_t MallocTracer::topAllocators(int num) const allocators_t::value_type& b) { return a.first.count < b.first.count; }); - if(num > 0) + if((unsigned int)num > ret.size()) + ret.clear(); + else if(num > 0) ret.erase(ret.begin(), ret.begin() + (ret.size() - num)); l_active=false; return ret;