]> granicus.if.org Git - pdns/commitdiff
kill some further mallocs and add note to remind us not to add them back auth-3.3.2
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 6 Jan 2015 11:49:31 +0000 (12:49 +0100)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Fri, 1 May 2015 07:05:37 +0000 (09:05 +0200)
Conflicts:
pdns/dnsparser.cc

pdns/dnsparser.cc

index 5415290eb2ee4630c9f59b21afd0a578e90349d2..5fe05c43dc84499280332a79c9cbcc60fac47f60 100644 (file)
@@ -437,6 +437,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
     throw MOADNSException("Loop");
 
   int pos = frompos;
+  // 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++);
 
@@ -455,7 +456,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
     }
     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, '\\');