}\r
\r
LengthToReturn = 0;\r
+ EndBuffer = NULL;\r
+ OriginalBuffer = NULL;\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
- //\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
// 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