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

Resource Leak in thrift struct under compiler/cpp/src/parse/t_function.h

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9
    • 0.9.2
    • C++ - Compiler
    • cpp compiler of thrift 0.9.0 on Linux 2.6.32-220.el6.x86_64

    • Patch Available

    Description

      In file compiler/cpp/src/parse/t_function.h

      class t_function : public t_doc {
      35 public:
      36 t_function(t_type* returntype,
      37 std::string name,
      38 t_struct* arglist,
      39 bool oneway=false) :
      40 returntype_(returntype),
      41 name_(name),
      42 arglist_(arglist),
      43 oneway_(oneway)

      { 44 xceptions_ = new t_struct(NULL); In Line number 44 1. Allocating memory by calling "new t_struct(NULL)". 2. Assigning "this->xceptions_" = "new t_struct(NULL)". 3. The constructor allocates field "xceptions_" of "t_function" but the destructor and whatever functions it calls do not free it. 45 }

      This is the destructor implementation.
      63 ~t_function() {}

      destructor should deallocate memroy for xceptions_. but destructor implementation does not do resource deallocation.
      which sometimes causes Resource Leak.

      Possible patch:
      ~t_function() {
      delete xceptions_;
      xceptions_ = NULL;
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            kuldeepgupta kuldeep gupta
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: