Skip to content

Commit 25ed902

Browse files
committed
MdeModulePkg: Prevent memcpy intrinsics in VS22 (17.14.2)
The latest VS2022 update replaces some code patterns with struct assignments with `memcpy`. This change convert the code to explicitly use `CopyMem`. Signed-off-by: Michael Kubacki <[email protected]>
1 parent 74d60ca commit 25ed902

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

MdeModulePkg/Universal/DisplayEngineDxe/InputHandler.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,16 @@ ReadString (
228228

229229
case CHAR_BACKSPACE:
230230
if ((StringPtr[0] != CHAR_NULL) && (CurrentCursor != 0)) {
231-
for (Index = 0; Index < CurrentCursor - 1; Index++) {
232-
TempString[Index] = StringPtr[Index];
231+
// MU_CHANGE [BEGIN]: Fix VS22 17.14 memcpy substitution
232+
// for (Index = 0; Index < CurrentCursor - 1; Index++) {
233+
// TempString[Index] = StringPtr[Index];
234+
// }
235+
if (CurrentCursor > 1) {
236+
CopyMem (TempString, StringPtr, (CurrentCursor - 1) * sizeof (CHAR16));
233237
}
234238

239+
// MU_CHANGE [END]: Fix VS22 17.14 memcpy substitution
240+
235241
Count = GetStringWidth (StringPtr) / 2 - 1;
236242
if (Count >= CurrentCursor) {
237243
for (Index = CurrentCursor - 1, Index2 = CurrentCursor; Index2 < Count; Index++, Index2++) {
@@ -260,9 +266,12 @@ ReadString (
260266
KeyPad[1] = CHAR_NULL;
261267
Count = GetStringWidth (StringPtr) / 2 - 1;
262268
if (CurrentCursor < Count) {
263-
for (Index = 0; Index < CurrentCursor; Index++) {
264-
TempString[Index] = StringPtr[Index];
265-
}
269+
// MU_CHANGE [BEGIN]: Fix VS22 17.14 memcpy substitution
270+
// for (Index = 0; Index < CurrentCursor; Index++) {
271+
// TempString[Index] = StringPtr[Index];
272+
// }
273+
CopyMem (TempString, StringPtr, CurrentCursor * sizeof (CHAR16));
274+
// MU_CHANGE [END]: Fix VS22 17.14 memcpy substitution
266275

267276
TempString[Index] = CHAR_NULL;
268277
StrCatS (TempString, MaxLen, KeyPad);

0 commit comments

Comments
 (0)