[ 
https://issues.apache.org/jira/browse/THRIFT-2016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13728867#comment-13728867
 ] 

Jens Geyer commented on THRIFT-2016:
------------------------------------

@[~kuldeepgupta], 

-1

did you test that? I get an exception after applying 
[^thrift-jira-thrift-2016_resource_leak.patch]. Probably due to the fact that 
the exception list is not owned by the {{t_function}} when the second CTOR is 
used. 


                
> Resource Leak in thrift struct under compiler/cpp/src/parse/t_function.h
> ------------------------------------------------------------------------
>
>                 Key: THRIFT-2016
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2016
>             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
>              Labels: patch
>         Attachments: thrift-jira-thrift-2016_resource_leak.patch
>
>
> 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;
> }

--
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