From a833f286fbc57c872bb073c2b1d7aa978a39efd2 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Wed, 21 Jan 2009 05:37:27 +0000 Subject: [PATCH] Update to add the ASSERT()s in the right place. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7325 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Library/GenericBdsLib/BdsMisc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Library/GenericBdsLib/BdsMisc.c b/MdeModulePkg/Library/GenericBdsLib/BdsMisc.c index 5779aec725..b9e6ae7ef3 100644 --- a/MdeModulePkg/Library/GenericBdsLib/BdsMisc.c +++ b/MdeModulePkg/Library/GenericBdsLib/BdsMisc.c @@ -270,11 +270,14 @@ BdsLibRegisterNewOption ( &gEfiGlobalVariableGuid, &TempOptionSize ); - ASSERT (TempOptionPtr != NULL); // - // Compare with current option variable + // Compare with current option variable if the previous option is set in global variable. // for (Index = 0; Index < TempOptionSize / sizeof (UINT16); Index++) { + // + // TempOptionPtr must not be NULL if we have non-zero TempOptionSize. + // + ASSERT (TempOptionPtr != NULL); if (*VariableName == 'B') { UnicodeSPrint (OptionName, sizeof (OptionName), L"Boot%04x", TempOptionPtr[Index]); @@ -336,8 +339,10 @@ BdsLibRegisterNewOption ( if (UpdateDescription) { // - // The number in option#### to be updated + // The number in option#### to be updated. + // In this case, we must have non-NULL TempOptionPtr. // + ASSERT (TempOptionPtr != NULL); RegisterOptionNumber = TempOptionPtr[Index]; } else { // @@ -393,14 +398,17 @@ BdsLibRegisterNewOption ( } return Status; } - + + // + // TempOptionPtr must not be NULL if TempOptionSize is not zero. + // + ASSERT (TempOptionPtr != NULL); // // Append the new option number to the original option order // OrderItemNum = (TempOptionSize / sizeof (UINT16)) + 1 ; OptionOrderPtr = AllocateZeroPool ( OrderItemNum * sizeof (UINT16)); ASSERT (OptionOrderPtr!= NULL); - CopyMem (OptionOrderPtr, TempOptionPtr, (OrderItemNum - 1) * sizeof (UINT16)); OptionOrderPtr[Index] = RegisterOptionNumber; -- 2.39.2