open-source-parsers/jsoncpp

Large floats not accepted anymore

Open

#1.349 aberto em 28 de out. de 2021

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)C++ (2.602 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (7.542 stars)
Métricas de merge de PR
 (Mesclagem média 18h 26m) (10 fundiu PRs em 30d)

Description

Describe the bug Version 1.9.2 no longer accepts 1+e9999 (or 2e+308 and anything above), regardless of allowSpecialFloats setting.

To Reproduce Steps to reproduce the behavior:

#include <iostream>
#include <json/json.h>
#include <sstream>

int main(int argc, const char* argv[])
{
    Json::CharReaderBuilder reader;
    reader["allowSpecialFloats"] = true;  // Makes no difference

    std::string s = "1e+9999";
    Json::Value val;
    std::string errors;
    std::stringstream json(s);
    if (Json::parseFromStream(reader, json, &val, &errors)) {
        std::cout << s << " -> " << val.asDouble() << "\n";
    } else {
        std::cout << errors;
    }
    return 0;
}

Expected behavior

  • 1e+9999 -> inf

Actual behavior:

* Line 1, Column 1
  '1e+9999' is not a number.

Desktop (please complete the following information):

  • OS: Fedora 34
  • Meson version 0.59.1
  • Ninja version 1.10.2

Additional context

  • Version 1.9.1 accepts value 1e+9999 as infinite, regardless of allowSpecialFloats setting.
  • Version 1.9.2 no longer accepts 2e+308 or above, regardless of allowSpecialFloats setting.

Specifically breaking change seems to be commit 645cd0412c "Number fixes (#1053)".

Guia do colaborador