]> Zhao Yanbai Git Server - minix.git/commitdiff
mail: close `fp` after use 92/3292/1
authorThomas Cort <tcort@minix3.org>
Sun, 7 Feb 2016 13:18:01 +0000 (13:18 +0000)
committerThomas Cort <tcort@minix3.org>
Sun, 7 Feb 2016 14:50:08 +0000 (09:50 -0500)
Add missing `fclose(fp)`

Issue #109

Change-Id: I0908ede77cba18336c399c5e16771cb6650e6404

minix/commands/mail/mail.c

index 1326ca50cbf7cc1e818a15bd4e5d96a75f8c2ea1..e9a553fb91391da32307f387e8a23f415328bc03 100644 (file)
@@ -757,11 +757,15 @@ void dohelp()
   FILE *fp;
   char buffer[80];
 
-  if ( (fp = fopen(HELPFILE, "r")) == NULL)
+  if ( (fp = fopen(HELPFILE, "r")) == NULL) {
        fprintf(stdout, "can't open helpfile %s\n", HELPFILE);
-  else
-       while (fgets(buffer, 80, fp))
-               fputs(buffer, stdout);
+       return;
+  }
+
+  while (fgets(buffer, 80, fp))
+       fputs(buffer, stdout);
+
+  fclose(fp);
 }
 
 int filesize(name)