Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
0.9
-
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)
67
68 t_program(std::string path) :
69 path_(path),
70 out_path_("./"),
71 out_path_is_absolute_(false)
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;
}