From 64948fa7015874e35338924644cadbcd1abc6986 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 22 Sep 2019 19:51:39 +0200 Subject: [PATCH] LibC: ungetc(EOF) should fail (and return EOF) --- Libraries/LibC/stdio.cpp | 2 ++ 1 file changed, 2 insertions(+) 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;