Explorar o código

check result of fgets in testcpg.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2082 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake %!s(int64=17) %!d(string=hai) anos
pai
achega
043de4d80a
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      test/testcpg.c

+ 5 - 1
test/testcpg.c

@@ -166,6 +166,7 @@ int main (int argc, char *argv[]) {
 	const char *options = "i";
 	int opt;
 	unsigned int nodeid;
+	char *fgets_res;
 
 	while ( (opt = getopt(argc, argv, options)) != -1 ) {
 		switch (opt) {
@@ -216,7 +217,10 @@ int main (int argc, char *argv[]) {
 			char inbuf[132];
 			struct iovec iov;
 
-			fgets(inbuf, sizeof(inbuf), stdin);
+			fgets_res = fgets(inbuf, sizeof(inbuf), stdin);
+			if (fgets_res == NULL) {
+				cpg_leave(handle, &group_name);
+			}
 			if (strncmp(inbuf, "EXIT", 4) == 0) {
 				cpg_leave(handle, &group_name);
 			}