Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Harry Liebel <Harry.Liebel@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
Reviewed-by: Gao, Liming <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15646
6f19259b-4bc3-4df7-8a09-
765794883524
}\r
\r
LengthToReturn = 0;\r
}\r
\r
LengthToReturn = 0;\r
+ EndBuffer = NULL;\r
+ OriginalBuffer = NULL;\r
\r
//\r
// Reserve space for the Null terminator.\r
//\r
\r
//\r
// Reserve space for the Null terminator.\r
//\r
- BufferSize--;\r
- OriginalBuffer = Buffer;\r
+ if (Buffer != NULL) {\r
+ BufferSize--;\r
+ OriginalBuffer = Buffer;\r
- //\r
- // Set the tag for the end of the input Buffer.\r
- //\r
- EndBuffer = Buffer + BufferSize * BytesPerOutputCharacter;\r
+ //\r
+ // Set the tag for the end of the input Buffer.\r
+ //\r
+ EndBuffer = Buffer + BufferSize * BytesPerOutputCharacter;\r
+ }\r
\r
if ((Flags & FORMAT_UNICODE) != 0) {\r
//\r
\r
if ((Flags & FORMAT_UNICODE) != 0) {\r
//\r
//\r
// Loop until the end of the format string is reached or the output buffer is full\r
//\r
//\r
// Loop until the end of the format string is reached or the output buffer is full\r
//\r
- while (FormatCharacter != 0 && Buffer < EndBuffer) {\r
+ while (FormatCharacter != 0) {\r
+ if ((Buffer != NULL) && (Buffer >= EndBuffer)) {\r
+ break;\r
+ }\r
//\r
// Clear all the flag bits except those that may have been passed in\r
//\r
//\r
// Clear all the flag bits except those that may have been passed in\r
//\r