The function originates from SunOS 4.x in which the null argument is allowed. glibc also handles this case.
@@ -10,7 +10,7 @@ FILE *setmntent(const char *name, const char *mode)
int endmntent(FILE *f)
{
- fclose(f);
+ if (f) fclose(f);
return 1;
}