From 72911cd00665ecbdc91269f67bee237d458d6bba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Wi=C5=9Bniewski?= Date: Sun, 31 Mar 2024 20:13:37 +0200 Subject: [PATCH] LibC: Verify pointer returned by `malloc()` --- Userland/Libraries/LibC/unistd.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp index 4db929e3b9b..35417068ac3 100644 --- a/Userland/Libraries/LibC/unistd.cpp +++ b/Userland/Libraries/LibC/unistd.cpp @@ -448,6 +448,9 @@ static int ttyname_r_for_directory(char const* directory_name, dev_t device_mode } name_path = (char*)malloc(name_length); + // FIXME: ttyname_r() is not allowed to return ENOMEM, find better way to store name_path, + // perhaps a static storage. + VERIFY(name_path); memset(name_path, 0, name_length); memcpy(name_path, directory_name, strlen(directory_name)); memcpy(&name_path[strlen(directory_name)], entry->d_name, strlen(entry->d_name));