]> git.tdb.fi Git - libs/datafile.git/commitdiff
Reserve enough storage for the output in base64_decode
authorMikko Rasa <tdb@tdb.fi>
Sun, 18 Apr 2021 12:05:19 +0000 (15:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 18 Apr 2021 12:05:19 +0000 (15:05 +0300)
source/textparser.cpp

index 7ea0600f8565a5fc743fc0d44c10bf76db3af0f9..d467de8582ef323367538ec8dbfd8f03a5e54272 100644 (file)
@@ -314,6 +314,7 @@ bool TextParser::isodigit(int c)
 string TextParser::base64_decode(const string &data)
 {
        string bin;
+       bin.reserve(data.size()*3/4);
        unsigned accum = 0;
        unsigned a_bits = 0;
        for(string::const_iterator i=data.begin(); i!=data.end(); ++i)