Add check to avoid null pointer deference.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15410 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ruiyu Ni 2014-03-28 02:50:47 +00:00 committed by niruiyu
parent 3a4b498ee1
commit c4571f0479
2 changed files with 8 additions and 4 deletions

View File

@ -217,6 +217,9 @@ BdsLibRegisterNewOption (
UINT16 BootOrderEntry;
UINTN OrderItemNum;
if (DevicePath == NULL) {
return EFI_INVALID_PARAMETER;
}
OptionPtr = NULL;
OptionSize = 0;
@ -1551,7 +1554,9 @@ SetVariableAndReportStatusCodeOnError (
SetVariableStatus->SetStatus = Status;
SetVariableStatus->Attributes = Attributes;
CopyMem (SetVariableStatus + 1, VariableName, NameSize);
CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data, DataSize);
if ((Data != NULL) && (DataSize != 0)) {
CopyMem (((UINT8 *) (SetVariableStatus + 1)) + NameSize, Data, DataSize);
}
REPORT_STATUS_CODE_EX (
EFI_ERROR_CODE,

View File

@ -408,19 +408,18 @@ InitializeLangVariable (
IN BOOLEAN Iso639Language
)
{
EFI_STATUS Status;
CHAR8 *Lang;
//
// Find current Lang or PlatformLang from EFI Variable.
//
Status = GetEfiGlobalVariable2 (LangName, (VOID **) &Lang, NULL);
GetEfiGlobalVariable2 (LangName, (VOID **) &Lang, NULL);
//
// If Lang or PlatformLang variable is not found,
// or it has been set to an unsupported value(not one of the supported language codes),
// set the default language code to it.
//
if (EFI_ERROR (Status) || !IsLangInSupportedLangCodes (SupportedLang, Lang, Iso639Language)) {
if ((Lang == NULL) || !IsLangInSupportedLangCodes (SupportedLang, Lang, Iso639Language)) {
//
// The default language code should be one of the supported language codes.
//