]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
malloctrace would crash if you asked it for more topAllocators than there were
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 17 Aug 2016 09:12:55 +0000 (11:12 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 17 Aug 2016 09:12:55 +0000 (11:12 +0200)
pdns/malloctrace.cc

index 750782c78a96345bd3ff41681897ec8f268a5fe3..e58add9b62dd9bcec3f7bb1dba26050d736e0c95 100644 (file)
@@ -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;