Unsigned variable compared < 0

When filling the screen with spaces, the code was subtracting two
unsigned numbers and checking if they were negative. Changed to use a
comparison and adjust the subtraction as appropriate, then did the rest
of the size expansion. If the second point is before the first, set the
fill length to 0.

Affected function: wolfSSH_ClearScreen.
Issue: F-48
pull/892/head
John Safranek 2026-03-09 14:16:57 -07:00
parent 6a3e97d12b
commit 331048d701
1 changed files with 8 additions and 7 deletions

View File

@ -115,14 +115,15 @@ static void wolfSSH_ClearScreen(WOLFSSH_HANDLE handle, word32 x1, word32 y1, wor
start.Y = y1;
/* get number of cells */
if (y1 == y2) { /* on same line so is x2 - x1 */
fill = x2 - x1;
if (y2 == y1) { /* on same line so is x2 - x1 */
fill = (x2 >= x1) ? (x2 - x1) : 0;
}
else { /* | y1 - y2 | * maxX - x1 + x2 */
fill = y1 - y2;
if (fill < 0)
fill += fill * 2;
fill = fill * maxX - x1 + x2;
/* (y2 - y1) * maxX - x1 + x2 */
else if (y2 > y1) {
fill = (y2 - y1) * maxX - x1 + x2;
}
else {
fill = 0;
}
FillConsoleOutputCharacterA(handle, ' ', fill, start, &w);