diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c
index 25962f85b2..fa96d1c1ee 100644
--- a/MdePkg/Library/BaseLib/String.c
+++ b/MdePkg/Library/BaseLib/String.c
@@ -1,7 +1,7 @@
/** @file
Unicode and ASCII string primitives.
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -315,6 +315,7 @@ StrnCmp (
}
while ((*FirstString != L'\0') &&
+ (*SecondString != L'\0') &&
(*FirstString == *SecondString) &&
(Length > 1)) {
FirstString++;
@@ -1474,6 +1475,7 @@ AsciiStrnCmp (
}
while ((*FirstString != '\0') &&
+ (*SecondString != '\0') &&
(*FirstString == *SecondString) &&
(Length > 1)) {
FirstString++;