From a3bcff0db8fa0d9eebd8803dfc72bfe92565bd70 Mon Sep 17 00:00:00 2001 From: Sahan Fernando Date: Thu, 10 Dec 2020 00:14:56 +1100 Subject: [PATCH] Userland: Fix segfault in sort --- Userland/sort.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/sort.cpp b/Userland/sort.cpp index 5eb520b1eb..83b96b3448 100644 --- a/Userland/sort.cpp +++ b/Userland/sort.cpp @@ -47,8 +47,9 @@ int main(int argc, char** argv) for (;;) { char* buffer = nullptr; ssize_t buflen = 0; + size_t n; errno = 0; - buflen = getline(&buffer, nullptr, stdin); + buflen = getline(&buffer, &n, stdin); if (buflen == -1 && errno != 0) { perror("getline"); exit(1);