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

Coverity analysis defect 72086: Unchecked dynamic_cast

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Testing Infrastructure
    • Fully Compatible
    • ALL
    • Quint Iteration 3

      Dynamic_cast may fail and return null if the type cast is incompatible

      Defect 72086 (STATIC_C)
      Checker FORWARD_NULL (subcategory dynamic_cast)
      File: /src/mongo/db/matcher/expression_algo.cpp
      Function mongo::expression::isClauseRedundant(const mongo::MatchExpression *, const mongo::MatchExpression *)
      /src/mongo/db/matcher/expression_algo.cpp, line: 279
      Dynamic cast to pointer "dynamic_cast <mongo::ExistsMatchExpression const *>(bar)" can return "NULL".

                          const ExistsMatchExpression* b = dynamic_cast<const ExistsMatchExpression*>(bar);
      

      /src/mongo/db/matcher/expression_algo.cpp, line: 279
      Assigning: "b" = "dynamic_cast <mongo::ExistsMatchExpression const *>(bar)".

                          const ExistsMatchExpression* b = dynamic_cast<const ExistsMatchExpression*>(bar);
      

      /src/mongo/db/matcher/expression_algo.cpp, line: 281
      Passing null pointer "b" to "path", which dereferences it. (The dereference happens because this is a virtual function call.)

                          return a->path() == b->path();
      

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            xgen-internal-coverity Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: