BIND 10 trac2442, updated. ea88e8907ab138e2fa1c5271c8a03ec53b4b08d0 [2442] updated comment for string::operator[] when it's empty

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Dec 5 18:44:55 UTC 2012


The branch, trac2442 has been updated
       via  ea88e8907ab138e2fa1c5271c8a03ec53b4b08d0 (commit)
       via  05fc975a3d825a10c8b9c8df509854f9f69d9c87 (commit)
      from  9002ffc08e7c7fba799e8b417a1d80b77a20973e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ea88e8907ab138e2fa1c5271c8a03ec53b4b08d0
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed Dec 5 10:43:06 2012 -0800

    [2442] updated comment for string::operator[] when it's empty
    
    this is actually ensured by the C++ standard lib spec.

commit 05fc975a3d825a10c8b9c8df509854f9f69d9c87
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Wed Dec 5 10:36:13 2012 -0800

    [2442] use std::string instead of POD array for constructing obj of DDD.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/rdata/generic/detail/char_string.cc |   13 +++++--------
 src/lib/dns/tests/rdata_char_string_unittest.cc |    2 +-
 2 files changed, 6 insertions(+), 9 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/rdata/generic/detail/char_string.cc b/src/lib/dns/rdata/generic/detail/char_string.cc
index e9f900a..b08111a 100644
--- a/src/lib/dns/rdata/generic/detail/char_string.cc
+++ b/src/lib/dns/rdata/generic/detail/char_string.cc
@@ -41,20 +41,17 @@ decimalToNumber(const char* s, const char* s_end) {
         isc_throw(InvalidRdataText, "Escaped digits too short");
     }
 
-    // Make a nul-terminated copy of the 'DDD' for lexical_cast
-    char buf[4];
-    std::memcpy(buf, s, 3);
-    buf[3] = 0;
-
+    const std::string num_str(s, s + 3);
     try {
-        const int i = boost::lexical_cast<int>(buf);
+        const int i = boost::lexical_cast<int>(num_str);
         if (i > 255) {
-            isc_throw(InvalidRdataText, "Escaped digits too large: " << buf);
+            isc_throw(InvalidRdataText, "Escaped digits too large: "
+                      << num_str);
         }
         return (i);
     } catch (const boost::bad_lexical_cast&) {
         isc_throw(InvalidRdataText,
-                  "Invalid form for escaped digits: " << buf);
+                  "Invalid form for escaped digits: " << num_str);
     }
 }
 }
diff --git a/src/lib/dns/tests/rdata_char_string_unittest.cc b/src/lib/dns/tests/rdata_char_string_unittest.cc
index 83f0591..9d23622 100644
--- a/src/lib/dns/tests/rdata_char_string_unittest.cc
+++ b/src/lib/dns/tests/rdata_char_string_unittest.cc
@@ -52,7 +52,7 @@ protected:
 MasterToken::StringRegion
 createStringRegion(const std::string& str) {
     MasterToken::StringRegion region;
-    region.beg = &str[0];       // note this works even if str is empty
+    region.beg = &str[0]; // note std ensures this works even if str is empty
     region.len = str.size();
     return (region);
 }



More information about the bind10-changes mailing list