]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2382] unify pushing '\0' for number-like data in Number::handle()
authorJINMEI Tatuya <jinmei@isc.org>
Tue, 4 Dec 2012 17:18:03 +0000 (09:18 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Tue, 4 Dec 2012 17:18:03 +0000 (09:18 -0800)
src/lib/dns/master_lexer.cc

index 4593b48b5fe95152f4b81cf37313ace060cd8568..b3b78c0e68a246154d48325298794b2733b612ec 100644 (file)
@@ -522,9 +522,10 @@ Number::handle(MasterLexer& lexer) const {
             getLexerImpl(lexer)->source_->getChar(), escaped);
         if (getLexerImpl(lexer)->isTokenEnd(c, escaped)) {
             getLexerImpl(lexer)->source_->ungetChar();
+            // We need to close the string whether it's digits-only (for
+            // lexical_cast) or not (see String::handle()).
+            data.push_back('\0');
             if (digits_only) {
-                // Close the string for lexical_cast
-                data.push_back('\0');
                 try {
                     const uint32_t number32 =
                         boost::lexical_cast<uint32_t, const char*>(&data[0]);
@@ -535,7 +536,6 @@ Number::handle(MasterLexer& lexer) const {
                     token = MasterToken(MasterToken::NUMBER_OUT_OF_RANGE);
                 }
             } else {
-                data.push_back('\0'); // see String::handle()
                 token = MasterToken(&data.at(0), data.size() - 1);
             }
             return;