[SERVER-64025] Coverity analysis defect 121570: Uninitialized scalar variable Created: 27/Feb/22  Updated: 29/Oct/23  Resolved: 14/Mar/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.0.0-rc0

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Yujin Kang Park
Resolution: Fixed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2022-03-21
Participants:

 Description   

Uninitialized scalar variable

The variable will contain an arbitrary value left from earlier computations. Use of an uninitialized variable
/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp:1100: UNINIT 121570 Declaring variable "wtRet" without initializer.
/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp:1168: UNINIT 121570 Using uninitialized value "wtRet".



 Comments   
Comment by Githook User [ 11/Mar/22 ]

Author:

{'name': 'Yu Jin Kang Park', 'email': 'yujin.kang@mongodb.com', 'username': 'yujin-kang'}

Message: SERVER-64025 Initialize wtRet and add non-zero check
Branch: master
https://github.com/mongodb/mongo/commit/0492ea43ae52b6102e6637b0cd745a2901e6bf06

Comment by Matt Kneiser [ 01/Mar/22 ]

Using git's pickaxe (git log -G / git log -S) it looks like this code was originally setup to like this (source: 014a3045):

 

int wtRet;
while ((wtRet = cursor->next(cursor)) == 0) {
  ...
}
 
if (wtRet != WT_NOTFOUND) {
}

In its current form, the assignment isn't in the while loop condition anymore
 

int wtRet;
while (backupBlocks.size() < batchSize) {
...
  if() {
    wtRet = (_wtBackup->cursor)->next(_wtBackup->cursor);
 ...
}
 
if (wtRet != WT_NOTFOUND) {
}

 

 

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