From 5256166e7ae38a89672f3a92e72d2ace93ae21dd Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 15 Oct 2022 16:06:41 +0200 Subject: [PATCH] libc: Fix strrchr --- libs/libc/src/string.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/libc/src/string.cpp b/libs/libc/src/string.cpp index dff7c8e2..958182d7 100644 --- a/libs/libc/src/string.cpp +++ b/libs/libc/src/string.cpp @@ -136,8 +136,9 @@ extern "C" char* strrchr(const char* str, int c) { const char* s = str + strlen(str); - while (s != str && *str != (char)c) str--; + while (s != str && *s != (char)c) s--; if (s != str) return const_cast(s); + if (*s == (char)c) return const_cast(s); return NULL; }