-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code
-
Fully Compatible
-
ALL
-
Query Execution 2021-05-31
This is the declaration of the RestoreContext class. Note that if the default constructor is selected, _collection will be permanently uninitialized garbage because it's const. The default constructor should probably be deleted instead as the intention appears to be to use one of the constructors that provides a collection pointer.
class RestoreContext { public: enum class RestoreType { kExternal, // Restore on the PlanExecutor by an external call kYield // Internal restore after yield }; RestoreContext() = default; // <--- should be deleted /* implicit */ RestoreContext(const CollectionPtr* coll) : _collection(coll) {} /* implicit */ RestoreContext(RestoreType type, const CollectionPtr* coll) : _type(type), _collection(coll) {} RestoreType type() const { return _type; } const CollectionPtr* collection() const { return _collection; } private: RestoreType _type = RestoreType::kExternal; const CollectionPtr* _collection; };
Uninitialized pointer field
The pointer field will point to an arbitrary memory location, any attempt to write may cause corruption. A pointer field is not initialized in the constructor
/src/mongo/db/query/restore_context.h:62: UNINIT_CTOR 119895 The compiler-generated constructor for this class does not initialize "_collection".