]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
kill some further mallocs and add note to remind us not to add them back
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 6 Jan 2015 11:49:31 +0000 (12:49 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 6 Jan 2015 11:49:31 +0000 (12:49 +0100)
pdns/dnsparser.cc

index 595a4afbdff345ec2e0bbac22cb20dc5bbfea76a..776b51a521a0e59eb9a9290a2665a50d710d7400 100644 (file)
@@ -457,7 +457,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
 {
   if(recurs > 1000) // the forward reference-check below should make this test 100% obsolete
     throw MOADNSException("Loop");
-
+  // it is tempting to call reserve on ret, but it turns out it creates a malloc/free storm in the loop
   for(;;) {
     unsigned char labellen=content.at(frompos++);
 
@@ -478,7 +478,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
       throw MOADNSException("Overly long label during label decompression ("+lexical_cast<string>((unsigned int)labellen)+")");
     else {
       // XXX FIXME THIS MIGHT BE VERY SLOW!
-      ret.reserve(ret.size() + labellen + 2);
+
       for(string::size_type n = 0 ; n < labellen; ++n, frompos++) {
         if(content.at(frompos)=='.' || content.at(frompos)=='\\') {
           ret.append(1, '\\');