Permalink
Browse files

kill some further mallocs and add note to remind us not to add them back

  • Loading branch information...
1 parent 0aaf0d3 commit 8682c32bc45b6ffa7c0f6da778e1b223ae7f03ce @ahupowerdns ahupowerdns committed Jan 6, 2015
Showing with 2 additions and 2 deletions.
  1. +2 −2 pdns/dnsparser.cc
View
@@ -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, '\\');

0 comments on commit 8682c32

Please sign in to comment.