public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdePkg/BaseMemoryLibOptDxe: check for zero length in ZeroMem ()
@ 2016-11-03 17:31 Ard Biesheuvel
  2016-11-03 17:38 ` Laszlo Ersek
  2016-11-03 17:38 ` Carsey, Jaben
  0 siblings, 2 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2016-11-03 17:31 UTC (permalink / raw)
  To: edk2-devel, michael.d.kinney, liming.gao; +Cc: Ard Biesheuvel

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.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c
index 2a0a038fd6c5..fbc2f5742c8c 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/ZeroMemWrapper.c
@@ -46,6 +46,10 @@ ZeroMem (
   IN UINTN  Length
   )
 {
+  if (Length == 0) {
+    return Buffer;
+  }
+
   ASSERT (!(Buffer == NULL && Length > 0));
   ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
   return InternalMemZeroMem (Buffer, Length);
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-03 18:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-03 17:31 [PATCH] MdePkg/BaseMemoryLibOptDxe: check for zero length in ZeroMem () Ard Biesheuvel
2016-11-03 17:38 ` Laszlo Ersek
2016-11-03 18:05   ` Ard Biesheuvel
2016-11-03 18:10     ` Laszlo Ersek
2016-11-03 17:38 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox