[SERVER-67544] Coverity analysis defect 122382: Uninitialized scalar field Created: 27/Jun/22  Updated: 29/Oct/23  Resolved: 01/Jul/22

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Ben Shteinfeld
Resolution: Fixed Votes: 0
Labels: coverity, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2022-06-27 at 10.55.46 AM.png    
Issue Links:
Related
related to SERVER-62206 Remove DBClientBase::query_DEPRECATED... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QO 2022-07-11
Participants:

 Description   

Uninitialized scalar field

The field will contain an arbitrary value left over from earlier computations. A scalar field is not initialized by the constructor
/src/mongo/db/cloner.cpp:226: UNINIT_CTOR 122382 Class member declaration for "numSeen".
/src/mongo/db/cloner.cpp:95: UNINIT_CTOR 122382 Non-static class member "numSeen" is not initialized in this constructor nor in any functions that it calls.
/src/mongo/db/cloner.cpp:230: UNINIT_CTOR 122382 Class member declaration for "saveLast".
/src/mongo/db/cloner.cpp:95: UNINIT_CTOR 122382 Non-static class member "saveLast" is not initialized in this constructor nor in any functions that it calls.



 Comments   
Comment by Githook User [ 30/Jun/22 ]

Author:

{'name': 'Ben Shteinfeld', 'email': 'ben.shteinfeld@mongodb.com', 'username': 'bshteinfeld'}

Message: SERVER-67544 Add initializer list for Cloner::BatchHandler
Branch: master
https://github.com/mongodb/mongo/commit/f2cc3316918773d13ba0349c94d7fe739d415569

Comment by Kyle Suarez [ 27/Jun/22 ]

While not caused by SERVER-62206, the changes in that commit caused Coverity to re-scan this file and it seems to have correctly detected these two uninitialized fields. We should simply add a default initializer.

Generated at Thu Feb 08 06:08:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.