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

Coverity analysis defect 57187: Division or modulo by float zero

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Testing Infrastructure
    • Fully Compatible
    • ALL

    Description

      An expression which may be zero is used as a divisor in floating-point arithmetic.

      Defect 57187 (STATIC_C)
      Checker DIVIDE_BY_ZERO (subcategory float_divisor)
      File: /src/mongo/db/fts/fts_spec_legacy.cpp
      Function mongo::fts::FTSSpec::_scoreStringV1(const mongo::fts::FTSSpec::Tools &, mongo::StringData, std::unordered_map<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, double, std::hash<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char>>, double>>> *, double) const
      /src/mongo/db/fts/fts_spec_legacy.cpp, line: 73
      Assigning: "numTokens" = "0U".

              unsigned numTokens = 0;

      /src/mongo/db/fts/fts_spec_legacy.cpp, line: 107
      In expression "0.5 * data.count / numTokens", division by expression "numTokens" which may be zero has undefined behavior.

                  double coeff = (0.5 * data.count / numTokens) + 0.5;

      Attachments

        Activity

          People

            rassi J Rassi
            xgen-internal-coverity Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: