Skip to content

Commit

Permalink
Fix LEPT_PARSE_NUMBER_TOO_BIG
Browse files Browse the repository at this point in the history
  • Loading branch information
miloyip committed Sep 21, 2016
1 parent 273b020 commit 7027c86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tutorial02_answer/leptjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int lept_parse_number(lept_context* c, lept_value* v) {
}
errno = 0;
v->n = strtod(c->json, NULL);
if (errno == ERANGE && v->n == HUGE_VAL) return LEPT_PARSE_NUMBER_TOO_BIG;
if (errno == ERANGE && (v->n == HUGE_VAL || v->n == -HUGE_VAL)) return LEPT_PARSE_NUMBER_TOO_BIG;
v->type = LEPT_NUMBER;
c->json = p;
return LEPT_PARSE_OK;
Expand Down
1 change: 1 addition & 0 deletions tutorial02_answer/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ static void test_parse_root_not_singular() {

static void test_parse_number_too_big() {
TEST_ERROR(LEPT_PARSE_NUMBER_TOO_BIG, "1e309");
TEST_ERROR(LEPT_PARSE_NUMBER_TOO_BIG, "-1e309");
}

static void test_parse() {
Expand Down

0 comments on commit 7027c86

Please sign in to comment.