Closed Bug 1259369 Opened 9 years ago Closed 9 years ago

[Static Analysis][Resource leak] In function Resolve from ice_unittest.cpp

Categories

(Core :: WebRTC: Networking, defect, P4)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1268449
Tracking Status
firefox48 --- affected

People

(Reporter: radu.stoica, Assigned: radu.stoica)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: CID 1355138)

Attachments

(1 file, 3 obsolete files)

possible resource leak - Variable res going out of scope leaks the storage it points to. The Static Analysis tool Coverity added, ice_unittest.cpp::120
Attached patch bug_1259369.diff (obsolete) (deleted) — Splinter Review
Attachment #8734296 - Flags: review?(ekr)
Attachment #8734296 - Flags: review?(docfaraday)
Summary: [Static Analysis] → [Static Analysis][Resource leak] In function Resolve
Attached patch bug_1259369.diff (obsolete) (deleted) — Splinter Review
Attachment #8734298 - Flags: review?(ekr)
Attachment #8734298 - Flags: review?(docfaraday)
Summary: [Static Analysis][Resource leak] In function Resolve → [Static Analysis][Resource leak] In function Resolve from ice_unittest.cpp
Comment on attachment 8734296 [details] [diff] [review] bug_1259369.diff Review of attachment 8734296 [details] [diff] [review]: ----------------------------------------------------------------- ::: media/mtransport/test/ice_unittest.cpp @@ +115,5 @@ > > if (!strlen(str_addr)) { > std::cerr << "inet_ntop failed" << std::endl; > } > + free(res); This is not correct. See the man page for getaddrinfo. All of the information returned by getaddrinfo() is dynamically allocated: the addrinfo structures themselves as well as the socket address structures and the canonical host name strings included in the addrinfo structures. Memory allocated for the dynamically allocated structures created by a successful call to getaddrinfo() is released by the freeaddrinfo() function. The ai pointer should be an addrinfo structure created by a call to getaddrinfo().
Attachment #8734296 - Flags: review?(ekr)
Attachment #8734296 - Flags: review?(docfaraday)
Attachment #8734296 - Flags: review-
thank you, I've changed the call from free to freeaddrinfo, see the second attachement
Comment on attachment 8734298 [details] [diff] [review] bug_1259369.diff Review of attachment 8734298 [details] [diff] [review]: ----------------------------------------------------------------- r+ with one change. ::: media/mtransport/test/ice_unittest.cpp @@ +111,3 @@ > std::cerr << "Got unexpected address family in DNS lookup: " > << res->ai_family << std::endl; > return ""; Let's remove this return; this will allow |res| to be cleaned up in this case, and doesn't significantly differ in behavior.
Attachment #8734298 - Flags: review?(docfaraday) → review+
Attached patch bug_1259369.diff (obsolete) (deleted) — Splinter Review
Attachment #8734340 - Flags: review?(ekr)
Attachment #8734340 - Flags: review?(docfaraday)
changes added
Comment on attachment 8734340 [details] [diff] [review] bug_1259369.diff Review of attachment 8734340 [details] [diff] [review]: ----------------------------------------------------------------- ::: media/mtransport/test/ice_unittest.cpp @@ -108,5 @@ > sizeof(str_addr)); > break; > - default: > - std::cerr << "Got unexpected address family in DNS lookup: " > - << res->ai_family << std::endl; Leave the default case in; we would like to have this logging. Just don't return.
Attachment #8734340 - Flags: review?(docfaraday)
Attached patch bug_1259369.diff (deleted) — Splinter Review
Attachment #8734296 - Attachment is obsolete: true
Attachment #8734298 - Attachment is obsolete: true
Attachment #8734340 - Attachment is obsolete: true
Attachment #8734298 - Flags: review?(ekr)
Attachment #8734340 - Flags: review?(ekr)
Attachment #8734345 - Flags: review?(ekr)
Comment on attachment 8734345 [details] [diff] [review] bug_1259369.diff Review of attachment 8734345 [details] [diff] [review]: ----------------------------------------------------------------- LGTM
Attachment #8734345 - Flags: review?(ekr) → review+
Rank: 45
Priority: -- → P4
Radu, is this patch ready to land?
Flags: needinfo?(radu.stoica)
I can land it
Assignee: radu.stoica → bogdan.postelnicu
Assignee: bogdan.postelnicu → radu.stoica
Status: NEW → RESOLVED
Closed: 9 years ago
Keywords: checkin-needed
Resolution: --- → DUPLICATE
(In reply to Andi-Bogdan Postelnicu from comment #13) > > *** This bug has been marked as a duplicate of bug 1268449 *** do you want to still land the patch here? The patch from Bug 1268449 seems has landed ?
Keywords: checkin-needed
Flags: needinfo?(radu.stoica)
No, the patch from bug 1268449 covers it.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: