summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg
diff options
context:
space:
mode:
authorOlivier Martin <olivier.martin@arm.com>2014-12-12 19:13:04 +0000
committeroliviermartin <oliviermartin@Edk2>2014-12-12 19:13:04 +0000
commitb4c222655c8182febba890019367609ac278b1ba (patch)
treed92ee186d8a1e45dcb33c7312a57ece806fdb933 /ArmPlatformPkg
parent830e5b8c0f8dda3c46313200e1464548b2b7d2a3 (diff)
downloadedk2-platforms-b4c222655c8182febba890019367609ac278b1ba.tar.xz
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
Diffstat (limited to 'ArmPlatformPkg')
-rw-r--r--ArmPlatformPkg/Bds/BootOption.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ArmPlatformPkg/Bds/BootOption.c b/ArmPlatformPkg/Bds/BootOption.c
index 5712d2ccb4..80982222e1 100644
--- a/ArmPlatformPkg/Bds/BootOption.c
+++ b/ArmPlatformPkg/Bds/BootOption.c
@@ -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;