]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/String.c
MdePkg BaseLib: Fix a corner case of Source and Destination overlap.
[mirror_edk2.git] / MdePkg / Library / BaseLib / String.c
index 227a0dc846dc42d56a070e765003fe25db69e58e..9505c5b21ecb210f39fd51fa8472ec418f68fdae 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Unicode and ASCII string primatives.\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -1040,7 +1040,7 @@ UnicodeStrToAsciiStr (
   //\r
   // Source and Destination should not overlap\r
   //\r
-  ASSERT ((UINTN) ((CHAR16 *) Destination -  Source) > StrLen (Source));\r
+  ASSERT ((UINTN) (Destination - (CHAR8 *) Source) >= StrSize (Source));\r
   ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source));\r
 \r
 \r
@@ -2008,9 +2008,9 @@ AsciiStrToUnicodeStr (
   // Source and Destination should not overlap\r
   //\r
   ASSERT ((UINTN) ((CHAR8 *) Destination - Source) > AsciiStrLen (Source));\r
-  ASSERT ((UINTN) (Source - (CHAR8 *) Destination) > (AsciiStrLen (Source) * sizeof (CHAR16)));\r
+  ASSERT ((UINTN) (Source - (CHAR8 *) Destination) >= (AsciiStrSize (Source) * sizeof (CHAR16)));\r
+\r
 \r
\r
   ReturnValue = Destination;\r
   while (*Source != '\0') {\r
     *(Destination++) = (CHAR16) *(Source++);\r