From 8682c32bc45b6ffa7c0f6da778e1b223ae7f03ce 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 --- pdns/dnsparser.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index 595a4afbd..776b51a52 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -457,7 +457,7 @@ void PacketReader::getLabelFromContent(const vector& 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& content, uint16_t& throw MOADNSException("Overly long label during label decompression ("+lexical_cast((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, '\\'); -- 2.49.0