Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Coverity detected the following resource leak.
IMO
if (fd == -1)
should be
if (owned_fd == -1)
.
// Duplicate the file descriptor because Libevent will take ownership 754 // and control the lifecycle separately. 755 // 756 // TODO(josephw): We can avoid duplicating the file descriptor in 757 // future versions of Libevent. In Libevent versions 2.1.2 and later, 758 // we may use `evbuffer_file_segment_new` and `evbuffer_add_file_segment` 759 // instead of `evbuffer_add_file`. 3. open_fn: Returning handle opened by dup. 4. var_assign: Assigning: owned_fd = handle returned from dup(fd). 760 int owned_fd = dup(fd); CID 1372873: Argument cannot be negative (REVERSE_NEGATIVE) [select issue] 5. Condition fd == -1, taking true branch. 761 if (fd == -1) { CID 1372872 (#1 of 1): Resource leak (RESOURCE_LEAK) 6. leaked_handle: Handle variable owned_fd going out of scope leaks the handle. 762 return Failure(ErrnoError("Failed to duplicate file descriptor")); 763 }
Attachments
Issue Links
- is required by
-
MESOS-6104 Potential FD double close in libevent's implementation of `sendfile`.
- Resolved