Explorar el Código

Check the return value of fgets to make sure we did not reach EOF or an error

Cédric Augonnet hace 15 años
padre
commit
2cc0d21605
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      src/util/file.c

+ 3 - 2
src/util/file.c

@@ -26,9 +26,10 @@ void _starpu_drop_comments(FILE *f)
 			case '#':
 			{
 				char s[128];
+				char *ret;
 				do {
-					fgets(s, sizeof(s), f);
-				} while (!strchr(s, '\n'));
+					ret = fgets(s, sizeof(s), f);
+				} while (ret && (!strchr(s, '\n')));
 			}
 			case '\n':
 				continue;