[
https://issues.apache.org/jira/browse/THRIFT-1522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14614665#comment-14614665
]
ASF GitHub Bot commented on THRIFT-1522:
----------------------------------------
GitHub user cmhe opened a pull request:
https://github.com/apache/thrift/pull/542
THRIFT-1522: Fixes Memory leak by wrapping getaddrinfo into a class.
Sponsored-by: Roger Meier <[email protected]>
Signed-off-by: Claudius Heine <[email protected]>
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/cmhe/thrift THRIFT-1522
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/542.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #542
----
commit 4828e52ffe6a8bd0cdd7c40b629143a5ec299e31
Author: Claudius Heine <[email protected]>
Date: 2015-07-06T07:14:25Z
THRIFT-1522: Fixes Memory leak by wrapping getaddrinfo into a class.
Sponsored-by: Roger Meier <[email protected]>
Signed-off-by: Claudius Heine <[email protected]>
----
> TServerSocket potential memory leak with addrinfo *res0
> -------------------------------------------------------
>
> Key: THRIFT-1522
> URL: https://issues.apache.org/jira/browse/THRIFT-1522
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Library
> Affects Versions: 0.8
> Environment: Unix, Windows
> Reporter: Peace C
> Priority: Minor
> Labels: TServerSocket, leak, memory, thrift
> Fix For: 1.0
>
>
> I noticed a potential memory leak in TServerSocket.cpp. The res0 pointer
> receives an allocation from getaddrinfo() but is only freed part of the time
> in a conditional branch. It should be outside of the if-else to ensure it's
> deallocated every time.
> I'm holding off on creating a patch in case I'm not understanding some hidden
> functionality in the socket library. Here is the code snippet:
> struct addrinfo *res0;
> ...
> getaddrinfo(NULL, port, &hints, &res0);
> ...
> if (! path_.empty())
> { ... }
> else
> {
> ...
> freeaddrinfo(res0); //Line 331 of TServerSocket.cpp
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)