diff --git a/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c index 294a27a753..0600dc289f 100644 --- a/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLib/SetMemWrapper.c @@ -47,6 +47,9 @@ SetMem ( IN UINT8 Value ) { - ASSERT (Size <= MAX_ADDRESS - (UINTN)Buffer + 1); + if (Size == 0) { + return Buffer; + } + ASSERT (Size - 1 <= MAX_ADDRESS - (UINTN)Buffer); return InternalMemSetMem (Buffer, Size, Value); } diff --git a/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c index 294a27a753..0600dc289f 100644 --- a/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibMmx/SetMemWrapper.c @@ -47,6 +47,9 @@ SetMem ( IN UINT8 Value ) { - ASSERT (Size <= MAX_ADDRESS - (UINTN)Buffer + 1); + if (Size == 0) { + return Buffer; + } + ASSERT (Size - 1 <= MAX_ADDRESS - (UINTN)Buffer); return InternalMemSetMem (Buffer, Size, Value); } diff --git a/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c index 294a27a753..0600dc289f 100644 --- a/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibRepStr/SetMemWrapper.c @@ -47,6 +47,9 @@ SetMem ( IN UINT8 Value ) { - ASSERT (Size <= MAX_ADDRESS - (UINTN)Buffer + 1); + if (Size == 0) { + return Buffer; + } + ASSERT (Size - 1 <= MAX_ADDRESS - (UINTN)Buffer); return InternalMemSetMem (Buffer, Size, Value); } diff --git a/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c b/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c index 294a27a753..0600dc289f 100644 --- a/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibSse2/SetMemWrapper.c @@ -47,6 +47,9 @@ SetMem ( IN UINT8 Value ) { - ASSERT (Size <= MAX_ADDRESS - (UINTN)Buffer + 1); + if (Size == 0) { + return Buffer; + } + ASSERT (Size - 1 <= MAX_ADDRESS - (UINTN)Buffer); return InternalMemSetMem (Buffer, Size, Value); } diff --git a/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c b/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c index 294a27a753..0600dc289f 100644 --- a/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c +++ b/MdePkg/Library/PeiMemoryLib/SetMemWrapper.c @@ -47,6 +47,9 @@ SetMem ( IN UINT8 Value ) { - ASSERT (Size <= MAX_ADDRESS - (UINTN)Buffer + 1); + if (Size == 0) { + return Buffer; + } + ASSERT (Size - 1 <= MAX_ADDRESS - (UINTN)Buffer); return InternalMemSetMem (Buffer, Size, Value); } diff --git a/MdePkg/Library/UefiMemoryLib/SetMemWrapper.c b/MdePkg/Library/UefiMemoryLib/SetMemWrapper.c index 294a27a753..0600dc289f 100644 --- a/MdePkg/Library/UefiMemoryLib/SetMemWrapper.c +++ b/MdePkg/Library/UefiMemoryLib/SetMemWrapper.c @@ -47,6 +47,9 @@ SetMem ( IN UINT8 Value ) { - ASSERT (Size <= MAX_ADDRESS - (UINTN)Buffer + 1); + if (Size == 0) { + return Buffer; + } + ASSERT (Size - 1 <= MAX_ADDRESS - (UINTN)Buffer); return InternalMemSetMem (Buffer, Size, Value); }