Always take a sizeof(WCHAR) into account when moving memory
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 32s
Builds / ExectOS (i686) (push) Successful in 30s

This commit is contained in:
Rafal Kupiec 2023-12-16 22:45:40 +01:00
parent 297b201f33
commit d8a260795e
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4

View File

@ -765,7 +765,7 @@ BlDisplayInputDialog(IN PWCHAR Caption,
{ {
if(InputFieldLength > 0 && TextPosition < InputFieldLength) if(InputFieldLength > 0 && TextPosition < InputFieldLength)
{ {
RtlMoveMemory(InputFieldBuffer + TextPosition, InputFieldBuffer + TextPosition + 1, InputFieldLength - TextPosition); RtlMoveMemory(InputFieldBuffer + TextPosition, InputFieldBuffer + TextPosition + 1, (InputFieldLength - TextPosition) * sizeof(WCHAR));
InputFieldLength--; InputFieldLength--;
InputFieldBuffer[InputFieldLength] = 0; InputFieldBuffer[InputFieldLength] = 0;
} }
@ -779,7 +779,7 @@ BlDisplayInputDialog(IN PWCHAR Caption,
if(InputFieldLength > 0 && TextPosition > 0 && TextPosition <= InputFieldLength) if(InputFieldLength > 0 && TextPosition > 0 && TextPosition <= InputFieldLength)
{ {
TextPosition--; TextPosition--;
RtlMoveMemory(InputFieldBuffer + TextPosition, InputFieldBuffer + TextPosition + 1, InputFieldLength - TextPosition); RtlMoveMemory(InputFieldBuffer + TextPosition, InputFieldBuffer + TextPosition + 1, (InputFieldLength - TextPosition) * sizeof(WCHAR));
InputFieldLength--; InputFieldLength--;
InputFieldBuffer[InputFieldLength] = 0; InputFieldBuffer[InputFieldLength] = 0;
} }
@ -796,7 +796,7 @@ BlDisplayInputDialog(IN PWCHAR Caption,
{ {
if(InputFieldLength < Handle.Width - 8 - 1 && TextPosition < Handle.Width - 8 - 1) if(InputFieldLength < Handle.Width - 8 - 1 && TextPosition < Handle.Width - 8 - 1)
{ {
RtlMoveMemory(InputFieldBuffer + TextPosition + 1, InputFieldBuffer + TextPosition, InputFieldLength - TextPosition); RtlMoveMemory(InputFieldBuffer + TextPosition + 1, InputFieldBuffer + TextPosition, (InputFieldLength - TextPosition) * sizeof(WCHAR));
InputFieldBuffer[TextPosition] = Key.UnicodeChar; InputFieldBuffer[TextPosition] = Key.UnicodeChar;
TextPosition++; TextPosition++;
InputFieldLength++; InputFieldLength++;