Thrift
  1. Thrift
  2. THRIFT-1522

TServerSocket potential memory leak with addrinfo *res0

    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 }

        Issue Links

          Activity

          Peace C created issue -
          Peace C made changes -
          Field Original Value New Value
          Labels TServerSocket leak memory thrift
          Jake Farrell made changes -
          Fix Version/s 1.0 [ 12318851 ]
          Fix Version/s 0.9 [ 12316294 ]
          Ben Craig made changes -
          Component/s C++ - Library [ 12312313 ]
          Component/s C# - Library [ 12312362 ]
          Ben Craig made changes -
          Link This issue duplicates THRIFT-1201 [ THRIFT-1201 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Peace C
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Development