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:
@@ -87,6 +87,10 @@ struct SPendingAssign {
|
||||
VOID SetAddrAndLen (IN VOID *, IN UINT32);
|
||||
VOID AssignValue (IN VOID *, IN UINT32);
|
||||
CHAR8 * GetKey (VOID);
|
||||
|
||||
private:
|
||||
SPendingAssign (IN CONST SPendingAssign&); // Prevent copy-construction
|
||||
SPendingAssign& operator= (IN CONST SPendingAssign&); // Prevent assignment
|
||||
};
|
||||
|
||||
struct SBufferNode {
|
||||
@@ -139,6 +143,10 @@ public:
|
||||
EFI_VFR_RETURN_CODE BuildPkg (OUT PACKAGE_DATA &);
|
||||
EFI_VFR_RETURN_CODE GenCFile (IN CHAR8 *, IN FILE *, IN PACKAGE_DATA *PkgData = NULL);
|
||||
|
||||
private:
|
||||
CFormPkg (IN CONST CFormPkg&); // Prevent copy-construction
|
||||
CFormPkg& operator= (IN CONST CFormPkg&); // Prevent assignment
|
||||
|
||||
public:
|
||||
EFI_VFR_RETURN_CODE AssignPending (IN CHAR8 *, IN VOID *, IN UINT32, IN UINT32, IN CONST CHAR8 *Msg = NULL);
|
||||
VOID DoPendingAssign (IN CHAR8 *, IN VOID *, IN UINT32);
|
||||
@@ -237,6 +245,10 @@ public:
|
||||
VOID IfrCreateDefaultForQuestion (IN SIfrRecord *, IN QuestionDefaultRecord *);
|
||||
VOID IfrParseDefaulInfoInQuestion (IN SIfrRecord *, OUT QuestionDefaultRecord *);
|
||||
VOID IfrAddDefaultToBufferConfig (IN UINT16, IN SIfrRecord *,IN EFI_IFR_TYPE_VALUE);
|
||||
|
||||
private:
|
||||
CIfrRecordInfoDB (IN CONST CIfrRecordInfoDB&); // Prevent copy-construction
|
||||
CIfrRecordInfoDB& operator= (IN CONST CIfrRecordInfoDB&); // Prevent assignment
|
||||
};
|
||||
|
||||
extern CIfrRecordInfoDB gCIfrRecordInfoDB;
|
||||
|
Reference in New Issue
Block a user