From b8215f465c5a05789ee3b53aefa7b5314e04c9d2 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Fri, 17 Apr 2009 01:46:37 +0000 Subject: [PATCH] Fix Insert opcode error. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8105 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Library/UefiHiiLib/HiiLib.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c index e337b23475..e1d8a64730 100644 --- a/MdeModulePkg/Library/UefiHiiLib/HiiLib.c +++ b/MdeModulePkg/Library/UefiHiiLib/HiiLib.c @@ -1158,10 +1158,10 @@ HiiIsConfigHdrMatch ( buffer. The returned buffer is allocated using AllocatePool(). The caller is responsible for freeing the returned buffer using FreePool(). - @param[in] VariableName Pointer to a Null-terminated Unicode string. This - is an optional parameter that may be NULL. @param[in] VariableGuid Pointer to an EFI_GUID structure. This is an optional parameter that may be NULL. + @param[in] VariableName Pointer to a Null-terminated Unicode string. This + is an optional parameter that may be NULL. @param[in] BufferSize Length in bytes of buffer to hold retrived data. @retval NULL The uncommitted data could not be retrieved. @@ -2267,17 +2267,19 @@ InternalHiiUpdateFormPackageData ( // Insert the updated data // UpdateIfrOpHdr = (EFI_IFR_OP_HEADER *) OpCodeBufferStart->Buffer; - AddOpCode = (EFI_IFR_OP_HEADER *) (OpCodeBufferStart->Buffer + UpdateIfrOpHdr->Length); AddSize = UpdateIfrOpHdr->Length; + AddOpCode = (EFI_IFR_OP_HEADER *) (OpCodeBufferStart->Buffer + AddSize); while (AddSize < OpCodeBufferStart->Position) { CopyMem (BufferPos, AddOpCode, AddOpCode->Length); BufferPos += AddOpCode->Length; UpdatePackageLength += AddOpCode->Length; - - AddOpCode = (EFI_IFR_OP_HEADER *) ((UINT8 *) (AddOpCode) + AddOpCode->Length); - AddSize += AddOpCode->Length; + + AddSize += AddOpCode->Length; + AddOpCode = (EFI_IFR_OP_HEADER *) (OpCodeBufferStart->Buffer + AddSize); } + ASSERT (AddSize == OpCodeBufferStart->Position); + if (OpCodeBufferEnd != NULL) { // // Add the end opcode -- 2.39.2