ArmPlatformPkg/Bds: Test if OptionalData is NULL before using it

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16515 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin 2014-12-12 19:13:04 +00:00 committed by oliviermartin
parent 830e5b8c0f
commit b4c222655c
1 changed files with 5 additions and 1 deletions

View File

@ -221,6 +221,8 @@ BootOptionSetFields (
WriteUnaligned32 ((UINT32 *)EfiLoadOptionPtr, ARM_BDS_OPTIONAL_DATA_SIGNATURE);
WriteUnaligned32 ((UINT32 *)(EfiLoadOptionPtr + 4), BootType);
// OptionalData should have been initialized by the caller of this function
ASSERT (OptionalData != NULL);
BootArguments = (ARM_BDS_LOADER_ARGUMENTS*)OptionalData;
SrcLinuxArguments = &(BootArguments->LinuxArguments);
DestLinuxArguments = &((ARM_BDS_LOADER_OPTIONAL_DATA*)EfiLoadOptionPtr)->Arguments.LinuxArguments;
@ -237,7 +239,9 @@ BootOptionSetFields (
CopyMem (InitrdPathListPtr, (VOID*)((UINTN)(SrcLinuxArguments + 1) + SrcLinuxArguments->CmdLineSize), SrcLinuxArguments->InitrdSize);
}
} else {
CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize);
if (OptionalData != NULL) {
CopyMem (BootOption->OptionalData, OptionalData, OptionalDataSize);
}
}
BootOption->OptionalDataSize = OptionalDataSize;