summaryrefslogtreecommitdiff
path: root/Libraries/LibC/stdio.cpp
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-03-26 10:09:31 +0300
committerAndreas Kling <kling@serenityos.org>2020-03-26 08:18:08 +0100
commit5ba8247cbbce239e33e756db3e80545682ebdae2 (patch)
tree202d8443ee473dee398059e1592b44d2805a4916 /Libraries/LibC/stdio.cpp
parentdb4da68618e8896cffa6b5164991308029160eb4 (diff)
downloadserenity-5ba8247cbbce239e33e756db3e80545682ebdae2.zip
LibC: Fix getline() forgetting to null-terminate on EOF
Diffstat (limited to 'Libraries/LibC/stdio.cpp')
-rw-r--r--Libraries/LibC/stdio.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/Libraries/LibC/stdio.cpp b/Libraries/LibC/stdio.cpp
index e0c289d518..8bcf059ff2 100644
--- a/Libraries/LibC/stdio.cpp
+++ b/Libraries/LibC/stdio.cpp
@@ -193,6 +193,7 @@ ssize_t getdelim(char** lineptr, size_t* n, int delim, FILE* stream)
int c = fgetc(stream);
if (c == -1) {
if (feof(stream)) {
+ *ptr = '\0';
return ptr == *lineptr ? -1 : ptr - *lineptr;
} else {
return -1;