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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9
    • 0.9.1
    • 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_program.h

      class t_program : public t_doc {
      59 public:
      60 t_program(std::string path, std::string name) :
      61 path_(path),
      62 name_(name),
      63 out_path_("./"),
      64 out_path_is_absolute_(false)

      { 65 scope_ = new t_scope(); 66 }

      67
      68 t_program(std::string path) :
      69 path_(path),
      70 out_path_("./"),
      71 out_path_is_absolute_(false)

      { 72 name_ = program_name(path); 73 scope_ = new t_scope(); 74 }

      In Above code at line number 65 and 73 Resource leaks happens as
      1. Allocating memory by calling "new t_scope".
      2. Assigning: "this->scope_" = "new t_scope".
      3. The constructor allocates field "scope_" of "t_program" but there is no destructor in the code.
      destructor should deallocate memroy for t_scope.
      which sometimes causes Resource Leak.

      Possible patch:
      There should be destructor to release the resources allocated dynamically.
      ~t_program() {
      delete scope_; scope_ = NULL;
      }

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: