Skip to content

Commit

Permalink
Fixed: Suspected possibility of very rare stall in Input::clear()
Browse files Browse the repository at this point in the history
  • Loading branch information
aristocratos committed Dec 11, 2021
1 parent 609dfcc commit 13a29c3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/btop_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ namespace Input {
}

void clear() {
auto first_num = cin.rdbuf()->in_avail();
while (cin.rdbuf()->in_avail() == first_num) {
if (first_num-- == 0) break;
cin.ignore(1);
if (auto first_num = cin.rdbuf()->in_avail(); first_num > 0) {
while (cin.rdbuf()->in_avail() == first_num) {
if (first_num-- <= 0) break;
cin.ignore(1);
}
}
}

Expand Down

0 comments on commit 13a29c3

Please sign in to comment.