From 386c7201d8d8e6900bf256cf5df08c30b6d9b5bb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 1 Sep 2020 16:15:30 +0200 Subject: [PATCH] LibC: Move the static String in getlogin() out of the function For some reason, this stops it from adding __cxa_guard_acquire/release calls around its initialization. This unbreaks building ports. --- Libraries/LibC/unistd.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp index 94ccc269757..22a8856751e 100644 --- a/Libraries/LibC/unistd.cpp +++ b/Libraries/LibC/unistd.cpp @@ -555,16 +555,17 @@ int set_process_icon(int icon_id) __RETURN_WITH_ERRNO(rc, rc, -1); } +static String getlogin_buffer; + char* getlogin() { - static String buffer; - if (buffer.is_null()) { + if (getlogin_buffer.is_null()) { if (auto* passwd = getpwuid(getuid())) { - buffer = String(passwd->pw_name); + getlogin_buffer = String(passwd->pw_name); } endpwent(); } - return const_cast(buffer.characters()); + return const_cast(getlogin_buffer.characters()); } int ftruncate(int fd, off_t length)