Browse Source

also check for -HUGE_VAL after strtod (+test of course)

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac172@2353 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen 15 years ago
parent
commit
0a9730cdd4
2 changed files with 2 additions and 1 deletions
  1. 1 1
      src/lib/cc/data.cc
  2. 1 0
      src/lib/cc/data_unittests.cc

+ 1 - 1
src/lib/cc/data.cc

@@ -374,7 +374,7 @@ from_stringstream_number(std::istream &in, int &pos) {
         if (*endptr != '\0') {
             isc_throw(JSONError, std::string("Bad number: ") + number);
         } else {
-            if (d == HUGE_VAL) {
+            if (d == HUGE_VAL || d == -HUGE_VAL) {
                 isc_throw(JSONError, std::string("Number overflow: ") + number);
             }
         }

+ 1 - 0
src/lib/cc/data_unittests.cc

@@ -155,6 +155,7 @@ TEST(Element, from_and_to_json) {
     // number overflows
     EXPECT_THROW(Element::fromJSON("12345678901234567890")->str(), JSONError);
     EXPECT_THROW(Element::fromJSON("1.1e12345678901234567890")->str(), JSONError);
+    EXPECT_THROW(Element::fromJSON("-1.1e12345678901234567890")->str(), JSONError);
     EXPECT_THROW(Element::fromJSON("1e12345678901234567890")->str(), JSONError);
     EXPECT_THROW(Element::fromJSON("1e50000")->str(), JSONError);