mirror of https://github.com/acidanthera/audk.git
Add check before use to make code run more safer.
Signed-off-by: ydong10 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12262 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
0c18794ea4
commit
6709bbd17f
|
@ -843,7 +843,7 @@ BasePrintLibSPrintMarker (
|
||||||
//
|
//
|
||||||
if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {
|
if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {
|
||||||
LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);
|
LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);
|
||||||
if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {
|
if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
|
||||||
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);
|
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -851,22 +851,22 @@ BasePrintLibSPrintMarker (
|
||||||
if (ZeroPad) {
|
if (ZeroPad) {
|
||||||
if (Prefix != 0) {
|
if (Prefix != 0) {
|
||||||
LengthToReturn += (1 * BytesPerOutputCharacter);
|
LengthToReturn += (1 * BytesPerOutputCharacter);
|
||||||
if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {
|
if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
|
||||||
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);
|
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);
|
LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);
|
||||||
if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {
|
if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
|
||||||
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter);
|
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);
|
LengthToReturn += ((Precision - Count) * BytesPerOutputCharacter);
|
||||||
if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {
|
if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
|
||||||
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter);
|
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
if (Prefix != 0) {
|
if (Prefix != 0) {
|
||||||
LengthToReturn += (1 * BytesPerOutputCharacter);
|
LengthToReturn += (1 * BytesPerOutputCharacter);
|
||||||
if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {
|
if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
|
||||||
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);
|
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -887,7 +887,7 @@ BasePrintLibSPrintMarker (
|
||||||
ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;
|
ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;
|
||||||
|
|
||||||
LengthToReturn += (1 * BytesPerOutputCharacter);
|
LengthToReturn += (1 * BytesPerOutputCharacter);
|
||||||
if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {
|
if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
|
||||||
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter);
|
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
ArgumentString += BytesPerArgumentCharacter;
|
ArgumentString += BytesPerArgumentCharacter;
|
||||||
|
@ -899,7 +899,7 @@ BasePrintLibSPrintMarker (
|
||||||
Index++;
|
Index++;
|
||||||
if (Index < Count) {
|
if (Index < Count) {
|
||||||
LengthToReturn += (1 * BytesPerOutputCharacter);
|
LengthToReturn += (1 * BytesPerOutputCharacter);
|
||||||
if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {
|
if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
|
||||||
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter);
|
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,7 @@ BasePrintLibSPrintMarker (
|
||||||
//
|
//
|
||||||
if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {
|
if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {
|
||||||
LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);
|
LengthToReturn += ((Width - Precision) * BytesPerOutputCharacter);
|
||||||
if ((Flags & COUNT_ONLY_NO_PRINT) == 0) {
|
if ((Flags & COUNT_ONLY_NO_PRINT) == 0 && Buffer != NULL) {
|
||||||
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);
|
Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -932,6 +932,7 @@ BasePrintLibSPrintMarker (
|
||||||
return (LengthToReturn / BytesPerOutputCharacter);
|
return (LengthToReturn / BytesPerOutputCharacter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT (Buffer != NULL);
|
||||||
//
|
//
|
||||||
// Null terminate the Unicode or ASCII string
|
// Null terminate the Unicode or ASCII string
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue