diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2016-11-03 17:29:01 +0000 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2016-11-04 09:53:01 +0000 |
commit | 12a37b2ae19b1edabf390c0744ae0af9bb9d2b9a (patch) | |
tree | bed19eb1d230a86c1dec90b1e58dd402c98ddc51 /MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c | |
parent | 669b6cc60bf610bbee32e79ed165ca604764c169 (diff) | |
download | edk2-platforms-12a37b2ae19b1edabf390c0744ae0af9bb9d2b9a.tar.xz |
MdePkg/BaseMemoryLib*: check for zero length in ZeroMem ()
Unlike other string functions in this library, ZeroMem () does not
return early when the length of the input buffer is 0. So add the
same to ZeroMem () as well, for all implementations of BaseMemoryLib
living under MdePkg/
This fixes an issue with the ARM implementation of BaseMemoryLibOPtDxe,
whose InternalMemZeroMem code does not expect a length of 0, and always
writes at least a single byte.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c')
-rw-r--r-- | MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c index 2a0a038fd6..9dd0b45e18 100644 --- a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c +++ b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c @@ -46,7 +46,11 @@ ZeroMem ( IN UINTN Length
)
{
- ASSERT (!(Buffer == NULL && Length > 0));
+ if (Length == 0) {
+ return Buffer;
+ }
+
+ ASSERT (Buffer != NULL);
ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
return InternalMemZeroMem (Buffer, Length);
}
|