INT32 *OldTextOutModeMap;\r
INT32 *SrcAddress;\r
INT32 Index;\r
+ UINTN OldStepSize;\r
+ UINTN NewStepSize;\r
\r
NewSize = Private->TextOutListCount * sizeof (INT32);\r
OldTextOutModeMap = Private->TextOutModeMap;\r
Size = Private->CurrentNumberOfConsoles * sizeof (INT32);\r
Index = 0;\r
SrcAddress = OldTextOutModeMap;\r
+ NewStepSize = NewSize / sizeof(INT32); \r
+ // If Private->CurrentNumberOfConsoles is not zero and OldTextOutModeMap\r
+ // is not NULL, it indicates that the original TextOutModeMap is not enough\r
+ // for the new console devices and has been enlarged by CONSOLE_SPLITTER_ALLOC_UNIT columns.\r
+ //\r
+ OldStepSize = NewStepSize - CONSOLE_SPLITTER_ALLOC_UNIT;\r
\r
//\r
// Copy the old data to the new one\r
//\r
while (Index < Private->TextOutMode.MaxMode) {\r
CopyMem (TextOutModeMap, SrcAddress, Size);\r
- TextOutModeMap += NewSize;\r
- SrcAddress += Size;\r
+ //\r
+ // Go to next row of new TextOutModeMap.\r
+ //\r
+ TextOutModeMap += NewStepSize;\r
+ //\r
+ // Go to next row of old TextOutModeMap.\r
+ //\r
+ SrcAddress += OldStepSize;\r
Index++;\r
}\r
//\r