BaseTools/C/Common: Avoid possible NULL pointer dereference
Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@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:
@ -650,6 +650,10 @@ Returns:
|
||||
ImageContext,
|
||||
RelocDir->VirtualAddress + RelocDir->Size - 1
|
||||
);
|
||||
if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd < RelocBase) {
|
||||
ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
|
||||
return RETURN_LOAD_ERROR;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Set base and end to bypass processing below.
|
||||
@ -674,6 +678,10 @@ Returns:
|
||||
ImageContext,
|
||||
RelocDir->VirtualAddress + RelocDir->Size - 1
|
||||
);
|
||||
if (RelocBase == NULL || RelocBaseEnd == NULL || RelocBaseEnd < RelocBase) {
|
||||
ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
|
||||
return RETURN_LOAD_ERROR;
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Set base and end to bypass processing below.
|
||||
@ -710,6 +718,10 @@ Returns:
|
||||
RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
|
||||
if (!(ImageContext->IsTeImage)) {
|
||||
FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
|
||||
if (FixupBase == NULL) {
|
||||
ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
|
||||
return RETURN_LOAD_ERROR;
|
||||
}
|
||||
} else {
|
||||
FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
|
||||
RelocBase->VirtualAddress +
|
||||
|
Reference in New Issue
Block a user