From dbedfc57e2556182d5a320d9b06b2bbf990bd8d3 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 6 Jan 2015 12:49:31 +0100 Subject: [PATCH] kill some further mallocs and add note to remind us not to add them back Conflicts: pdns/dnsparser.cc --- pdns/dnsparser.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index 5415290eb..5fe05c43d 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -437,6 +437,7 @@ void PacketReader::getLabelFromContent(const vector& 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& 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, '\\'); -- 2.40.0