diff --git a/sources/fflush.c b/sources/fflush.c index 263a984..5fdc1d6 100644 --- a/sources/fflush.c +++ b/sources/fflush.c @@ -2,7 +2,14 @@ int fflush(FILE *stream) { - stream->__pushback = EOF; - stream->__last_char = EOF; + /* + * streams are unbuffered, so there is nothing to write out. + * fflush(NULL) means "all streams" and must not dereference the pointer. + */ + if (stream != NULL) + { + stream->__pushback = EOF; + stream->__last_char = EOF; + } return 0; }