BaseTools/VfrCompile: Avoid freeing freed memory in classes

For classes that contain dynamically allocated data members, copy
constructor and assignment operator should be implemented or both
operations should be prohibited to avoid freeing freed memory caused by
shallow copy.

This commit declares both copy constructor and assignment operator as
'private' for classes that contain dynamically allocated data members.
This will prevent freeing already freed memory.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Hao Wu
2016-09-27 13:43:32 +08:00
parent 0d46defefa
commit 77dee0b185
4 changed files with 79 additions and 1 deletions

View File

@@ -119,6 +119,9 @@ public:
/* user must subclass this */
class DllExportPCCTS DLGLexerBase : public ANTLRTokenStream {
private:
DLGLexerBase(const DLGLexerBase&); // Prevent copy-construction
DLGLexerBase& operator=(const DLGLexerBase&); // Prevent assignment
public:
virtual ANTLRTokenType erraction();