Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1522

TServerSocket potential memory leak with addrinfo *res0

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      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 }

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            peace Peace C
            peace Peace C
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment