summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--com32/lib/fgets.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/com32/lib/fgets.c b/com32/lib/fgets.c
index 88a145a6..593bea36 100644
--- a/com32/lib/fgets.c
+++ b/com32/lib/fgets.c
@@ -17,11 +17,12 @@ char *fgets(char *s, int n, FILE *f)
ch = getc(f);
if ( ch == EOF ) {
*p = '\0';
- return NULL;
+ return (p == s) ? NULL : s;
}
*p++ = ch;
if ( ch == '\n' )
break;
+ n--;
}
if ( n )
*p = '\0';