MdePkg/BaseLib: Refine logic for (Ascii)StrnLenS to handle MaxSize = 0

https://bugzilla.tianocore.org/show_bug.cgi?id=378

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Hao Wu 2017-02-14 10:11:58 +08:00
parent 5e9e151c20
commit cb8674999c
1 changed files with 4 additions and 4 deletions

View File

@ -128,9 +128,9 @@ StrnLenS (
ASSERT (((UINTN) String & BIT0) == 0); ASSERT (((UINTN) String & BIT0) == 0);
// //
// If String is a null pointer, then the StrnLenS function returns zero. // If String is a null pointer or MaxSize is 0, then the StrnLenS function returns zero.
// //
if (String == NULL) { if ((String == NULL) || (MaxSize == 0)) {
return 0; return 0;
} }
@ -1097,9 +1097,9 @@ AsciiStrnLenS (
UINTN Length; UINTN Length;
// //
// If String is a null pointer, then the AsciiStrnLenS function returns zero. // If String is a null pointer or MaxSize is 0, then the AsciiStrnLenS function returns zero.
// //
if (String == NULL) { if ((String == NULL) || (MaxSize == 0)) {
return 0; return 0;
} }