[SERVER-50830] Coverity analysis defect 114690: Unchecked dynamic_cast Created: 09/Sep/20  Updated: 29/Oct/23  Resolved: 18/Sep/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.8.0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: George Wangensteen
Resolution: Fixed Votes: 0
Labels: coverity, coverity-pm-1854-tracking, greenerbuild, qopt-team
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-49363 Triage Coverity Issues for Query code... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

Unchecked dynamic_cast

If the dynamic_cast fails, a null pointer dereference will occur; if the dynamic_cast cannot fail, using static_cast instead offers better performance. Dynamic_cast may fail and return null if the type cast is incompatible
/src/mongo/db/pipeline/expression.cpp:6240: FORWARD_NULL 114690 Dynamic cast to pointer "dynamic_cast <mongo::ExpressionConstant *>(this->_regex->get())" can return "NULL".



 Comments   
Comment by Githook User [ 18/Sep/20 ]

Author:

{'name': 'George Wangensteen', 'email': 'george.wangensteen@mongodb.com'}

Message: SERVER-50830 fix unchecked dynamic cast
Branch: master
https://github.com/mongodb/mongo/commit/83cea6b8420511b8c38726074f2f54cab380f546

Comment by James Wahlin [ 09/Sep/20 ]

Maybe this should be a static_cast instead?

Generated at Thu Feb 08 05:23:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.