From: Trond Norbye Date: Tue, 24 Aug 2010 17:28:46 +0000 (+0200) Subject: Check the return code from fgets in memcapable X-Git-Tag: 0.44~2^2~7 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=677431851174f20bdbb6566700e22a9914c3e6fb;p=m6w6%2Flibmemcached Check the return code from fgets in memcapable --- diff --git a/clients/memcapable.c b/clients/memcapable.c index e64655b9..6ef5bc69 100644 --- a/clients/memcapable.c +++ b/clients/memcapable.c @@ -1944,16 +1944,17 @@ int main(int argc, char **argv) { fprintf(stdout, "\nPress when you are ready? "); char buffer[80] = {0}; - (void)fgets(buffer, sizeof(buffer), stdin); - if (strncmp(buffer, "skip", 4) == 0) - { - fprintf(stdout, "%-40s%s\n", testcases[ii].description, - status_msg[TEST_SKIP]); - fflush(stdout); - continue; + if (fgets(buffer, sizeof(buffer), stdin) != NULL) { + if (strncmp(buffer, "skip", 4) == 0) + { + fprintf(stdout, "%-40s%s\n", testcases[ii].description, + status_msg[TEST_SKIP]); + fflush(stdout); + continue; + } + if (strncmp(buffer, "quit", 4) == 0) + exit(0); } - if (strncmp(buffer, "quit", 4) == 0) - exit(0); fprintf(stdout, "%-40s", testcases[ii].description); fflush(stdout);