summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-22 19:51:39 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-22 19:51:39 +0200
commit64948fa7015874e35338924644cadbcd1abc6986 (patch)
tree7626eeb7d9dfc64ba5727f17029421348b03da8d
parentbba24b09f7fc49b41836711924df117d7a54b296 (diff)
downloadserenity-64948fa7015874e35338924644cadbcd1abc6986.zip
LibC: ungetc(EOF) should fail (and return EOF)
-rw-r--r--Libraries/LibC/stdio.cpp2
1 files changed, 2 insertions, 0 deletions
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;