[ 
https://issues.apache.org/jira/browse/THRIFT-2017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

kuldeep gupta updated THRIFT-2017:
----------------------------------

         Reproduced In: 0.9
            Patch Info: Patch Available
    Remaining Estimate:     (was: 96h)
     Original Estimate:     (was: 96h)
    
> Resource Leak in thrift struct under compiler/cpp/src/parse/t_program.h
> -----------------------------------------------------------------------
>
>                 Key: THRIFT-2017
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2017
>             Project: Thrift
>          Issue Type: Bug
>          Components: C++ - Compiler
>    Affects Versions: 0.9
>         Environment: cpp compiler of thrift 0.9.0 on Linux 
> 2.6.32-220.el6.x86_64
>            Reporter: kuldeep gupta
>
> 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; 
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to