Coverity analysis defect 72086: Unchecked dynamic_cast

XMLWordPrintableJSON

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

      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
            Reporter:
            Coverity Collector User
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: