Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-36576

Coverity analysis defect 104963: Not restoring ostream format

    • Fully Compatible
    • ALL
    • Platforms 2018-08-27, Platforms 2018-09-10

      Not restoring the stream format state of an ostream

      Defect 104963 (STATIC_C)
      Checker STREAM_FORMAT_STATE (subcategory none)
      File: /src/mongo/bson/bsonelement.cpp
      Function mongo::BSONElement::jsonStringStream(mongo::JsonStringFormat, bool, int, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>> &) const
      /src/mongo/bson/bsonelement.cpp, line: 90
      "precision" changes the format state of "s" for category precision.

                          s.precision(16);
      

      /src/mongo/bson/bsonelement.cpp, line: 314
      Changing format state of stream "s" for category precision without later restoring it.

          }
      

      File: /src/mongo/bson/bsonelement.cpp
      Function mongo::BSONElement::jsonStringStream(mongo::JsonStringFormat, bool, int, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>> &) const
      /src/mongo/bson/bsonelement.cpp, line: 209
      "hex" changes the format state of "s" for category basefield.

                      s << "\", \"$type\" : \"" << hex;
      

      /src/mongo/bson/bsonelement.cpp, line: 211
      "fill" changes the format state of "s" for category fill.

                      s.fill('0');
      

      /src/mongo/bson/bsonelement.cpp, line: 212
      "dec" changes the format state of "s" for category basefield.

                      s << type << dec;
      

      /src/mongo/bson/bsonelement.cpp, line: 314
      Changing format state of stream "s" for category fill without later restoring it.

          }
      

            Assignee:
            mark.benvenuto@mongodb.com Mark Benvenuto
            Reporter:
            xgen-internal-coverity Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: