Coverity analysis defect 98887: Division or modulo by zero

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • ALL
    • Query 14 (05/13/16)
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Division or modulo by zero results in undefined behavior.

      Defect 98887 (STATIC_C)
      Checker DIVIDE_BY_ZERO (subcategory none)
      File: /src/mongo/db/pipeline/expression.cpp
      Function mongo::ExpressionMod::evaluateInternal(mongo::Variables *) const
      /src/mongo/db/pipeline/expression.cpp, line: 1990
      Assigning: "rightLong" = "rhs.coerceToLong()". The value of "rightLong" is now 0.

                      long long rightLong = rhs.coerceToLong();
      

      /src/mongo/db/pipeline/expression.cpp, line: 1991
      In expression "left % rightLong", modulo by expression "rightLong" which may be zero has undefined behavior.

                      return Value(left % rightLong);
      

            Assignee:
            James Wahlin
            Reporter:
            Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: