From 5ba8247cbbce239e33e756db3e80545682ebdae2 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Thu, 26 Mar 2020 10:09:31 +0300 Subject: [PATCH] LibC: Fix getline() forgetting to null-terminate on EOF --- Libraries/LibC/stdio.cpp | 1 + 1 file changed, 1 insertion(+) 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;