Skip to content

Commit dbedfc5

Browse files
ahupowerdnsPeter van Dijk
authored andcommitted
kill some further mallocs and add note to remind us not to add them back
Conflicts: pdns/dnsparser.cc
1 parent 9df4944 commit dbedfc5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pdns/dnsparser.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
437437
throw MOADNSException("Loop");
438438

439439
int pos = frompos;
440+
// it is tempting to call reserve on ret, but it turns out it creates a malloc/free storm in the loop
440441
for(;;) {
441442
unsigned char labellen=content.at(frompos++);
442443

@@ -455,7 +456,7 @@ void PacketReader::getLabelFromContent(const vector<uint8_t>& content, uint16_t&
455456
}
456457
else {
457458
// XXX FIXME THIS MIGHT BE VERY SLOW!
458-
ret.reserve(ret.size() + labellen + 2);
459+
459460
for(string::size_type n = 0 ; n < labellen; ++n, frompos++) {
460461
if(content.at(frompos)=='.' || content.at(frompos)=='\\') {
461462
ret.append(1, '\\');

0 commit comments

Comments
 (0)