NetworkInfoServiceLinux.cpp: Possible socket resource leak

RESOLVED FIXED in Firefox 63

Status

()

P3
normal
RESOLVED FIXED
8 months ago
8 months ago

People

(Reporter: rbartlensky, Assigned: rbartlensky)

Tracking

unspecified
mozilla63
Points:
---

Firefox Tracking Flags

(firefox63 fixed)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 attachment)

(Assignee)

Description

8 months ago
The infer static analyzer reported a resource leak here: https://searchfox.org/mozilla-central/source/netwerk/base/NetworkInfoServiceLinux.cpp#64 and I think it might be right.

The autoCloseSocket is defined at https://searchfox.org/mozilla-central/source/netwerk/base/NetworkInfoServiceLinux.cpp#34-36 and it is a ScopeExit object. In this case it holds a file descriptor, and when it goes out of scope runs the system call close.

If the execution manages to reach https://searchfox.org/mozilla-central/source/netwerk/base/NetworkInfoServiceLinux.cpp#64 the ScopeExit object will no longer free the resource (because the release method sets a variable which makes the destructor skip the freeing of the resource), thus causing a resource leak.

It can be seen here: https://searchfox.org/mozilla-central/source/netwerk/base/NetworkInfoServiceLinux.cpp#57,69 that the file descriptor is passed to another function before executing the line in question, but the file descriptor is not closed anywhere.
Summary: Possible socket resource leak → NetworkInfoServiceLinux.cpp: Possible socket resource leak
Priority: -- → P3
Whiteboard: [necko-triaged]
Comment hidden (mozreview-request)
(Assignee)

Updated

8 months ago
Attachment #8989198 - Flags: review?(bpostelnicu)
Attachment #8989198 - Flags: review?(bpostelnicu) → review?(valentin.gosu)
I think valentin should take care of this review, since he's the reviewer for this component.

Comment 3

8 months ago
mozreview-review
Comment on attachment 8989198 [details]
Bug 1471943: Remove release call to ensure socket is closed.

https://reviewboard.mozilla.org/r/254250/#review261584

That's a good catch.
Attachment #8989198 - Flags: review?(valentin.gosu) → review+

Comment 4

8 months ago
Pushed by bpostelnicu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d53abfceeac2
Remove release call to ensure socket is closed. r=valentin

Comment 5

8 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/d53abfceeac2
Status: NEW → RESOLVED
Last Resolved: 8 months ago
status-firefox63: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.