Skip to content

Commit

Permalink
[TS-1306]<fix>: fix endless loop with utf-8 replacement character
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenkgu committed Mar 10, 2022
1 parent 01777f5 commit 62a05c0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/kit/shell/src/shellEngine.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ static void shellPrintNChar(const char *str, int length, int width) {
if (bytes <= 0) {
break;
}
if (pos + bytes > length) {
break;
}
int w = 0;
#ifdef WINDOWS
w = bytes;
Expand All @@ -555,15 +558,11 @@ static void shellPrintNChar(const char *str, int length, int width) {
w = wcwidth(wc);
}
#endif
pos += bytes;
if (w <= 0) {
continue;
}

pos += bytes;
if (pos > length) {
break;
}

if (width <= 0) {
printf("%lc", wc);
continue;
Expand Down

0 comments on commit 62a05c0

Please sign in to comment.