diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c index bf8e74dfb3..8bfd199e48 100644 --- a/MdeModulePkg/Universal/PCD/Dxe/Service.c +++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c @@ -746,6 +746,7 @@ SetWorker ( // GetPtrTypeSize (TokenNumber, &MaxSize); if (*Size > MaxSize) { + *Size = MaxSize; return EFI_INVALID_PARAMETER; } } else { diff --git a/MdeModulePkg/Universal/PCD/Pei/Service.c b/MdeModulePkg/Universal/PCD/Pei/Service.c index 4e7366e759..4769600da7 100644 --- a/MdeModulePkg/Universal/PCD/Pei/Service.c +++ b/MdeModulePkg/Universal/PCD/Pei/Service.c @@ -391,6 +391,7 @@ SetWorker ( // GetPtrTypeSize (TokenNumber, &MaxSize, PeiPcdDb); if (*Size > MaxSize) { + *Size = MaxSize; return EFI_INVALID_PARAMETER; } } else {