[SERVER-39601] Coverity analysis defect 111241: Resource leak Created: 15/Feb/19  Updated: 27/Oct/23  Resolved: 19/Feb/19

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

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: Jonathan Reams
Resolution: Works as Designed Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Sprint: Security 2019-02-25
Participants:

 Description   

Leak of memory or pointers to system resources

Defect 111241 (STATIC_C)
Checker RESOURCE_LEAK (subcategory none)
File: /src/mongo/util/net/hostname_canonicalization.cpp
Function mongo::getHostFQDNs(std::basic_string<char, std::char_traits<char>, std::allocator<char>>, mongo::HostnameCanonicalizationMode)
/src/mongo/util/net/hostname_canonicalization.cpp, line: 92
"shim_getaddrinfo" allocates memory that is stored into "info". (The function pointer resolves to "getaddrinfo".)

        if ((err = shim_getaddrinfo(nativeHostName.c_str(), nullptr, &hints, &info)) != 0) {

/src/mongo/util/net/hostname_canonicalization.cpp, line: 101
Variable "info" going out of scope leaks the storage it points to.

            return results;



 Comments   
Comment by Jonathan Reams [ 19/Feb/19 ]

I've ignored this in coverity.

Comment by Eric Milkie [ 19/Feb/19 ]

I recommend Ignore.

Comment by Jonathan Reams [ 19/Feb/19 ]

I agree that Coverity has been fooled a bit here. I'm not sure if it's because of the shim or because we're freeing info in a ScopeGuard in a slightly weird way. I think we can either ignore this, or I could put the info pointer into a unique_ptr instead?

Comment by Eric Milkie [ 19/Feb/19 ]

I think Coverity was just fooled by our shim.

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