Skip to content

Commit d62a933

Browse files
author
Bryan Concari
committed
Avoid infinite loop if stdin is closed prematurely in local_echo_demo.cpp
1 parent 8c9511e commit d62a933

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

example/local_echo_demo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ int main() {
134134
// get std::string from user
135135
// send string data over network connection
136136
std::string s;
137-
while (s != "quit\n") {
137+
while (s != "quit\n" && std::cin.good()) {
138138
std::cout << "> ";
139139
std::getline (std::cin, s);
140140
s += "\n"; // needed for deliminator

0 commit comments

Comments
 (0)