[SERVER-43836] Coverity analysis defect 10181: Resource leak Created: 04/Oct/19  Updated: 29/Oct/23  Resolved: 29/Oct/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.3.1

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Billy Donahue
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: Dev Tools 2019-11-04
Participants:

 Description   

Leak of memory or pointers to system resources

Defect 10181 (STATIC_C)
Checker RESOURCE_LEAK (subcategory none)
File: /src/mongo/shell/linenoise.cpp
Function InputBuffer::incrementalHistorySearch(PromptBase &, int)
/src/mongo/shell/linenoise.cpp, line: 1935
Storage is returned from allocation function "operator new[]".

                activeHistoryLine = new UChar32[bufferSize];

/src/mongo/shell/linenoise.cpp, line: 1935
Assigning: "activeHistoryLine" = storage returned from "new linenoise_utf8::UChar32[bufferSize]".

                activeHistoryLine = new UChar32[bufferSize];

/src/mongo/shell/linenoise.cpp, line: 1883
Overwriting "activeHistoryLine" in "activeHistoryLine = new linenoise_utf8::UChar32[bufferSize]" leaks the storage that "activeHistoryLine" points to.

                activeHistoryLine = new UChar32[bufferSize];



 Comments   
Comment by Githook User [ 28/Oct/19 ]

Author:

{'name': 'Billy Donahue', 'username': 'BillyDonahue', 'email': 'billy.donahue@mongodb.com'}

Message: SERVER-43836 use unique_ptr for activeHistoryLine to fix resource leak
Branch: master
https://github.com/mongodb/mongo/commit/2c7c6b5b58c0a7e2f3b214a298e2fb1915612b65

Comment by Billy Donahue [ 28/Oct/19 ]

https://mongodbcr.appspot.com/491520001/

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