diff --git a/Libraries/LibC/stdio.cpp b/Libraries/LibC/stdio.cpp index bce13c7f79..db3dc57451 100644 --- a/Libraries/LibC/stdio.cpp +++ b/Libraries/LibC/stdio.cpp @@ -190,6 +190,8 @@ ssize_t getline(char **lineptr, size_t *n, FILE *stream) int ungetc(int c, FILE* stream) { ASSERT(stream); + if (c == EOF) + return EOF; if (stream->have_ungotten) return EOF; stream->have_ungotten = true;