From: bert hubert Date: Tue, 6 Jan 2015 11:49:31 +0000 (+0100) Subject: kill some further mallocs and add note to remind us not to add them back X-Git-Tag: rec-3.7.0-rc1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8682c32bc45b6ffa7c0f6da778e1b223ae7f03ce;p=thirdparty%2Fpdns.git kill some further mallocs and add note to remind us not to add them back --- diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index 595a4afbdf..776b51a521 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, '\\');