diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c index b01a4187..cf5b1039 100644 --- a/src/stdio/fgets.c +++ b/src/stdio/fgets.c @@ -34,7 +34,7 @@ char *fgets(char *restrict s, int n, FILE *restrict f) n--; if ((*p++ = c) == '\n') break; } - *p = 0; + if (s) *p = 0; FUNLOCK(f);