From be649f03b3702f6d338c4c065a349fcbf3e5ae35 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 13 Oct 2015 12:50:28 +0200 Subject: fix strrchr bug, return the end of the string if c is 0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/string/strchr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/string/strchr.c') diff --git a/src/string/strchr.c b/src/string/strchr.c index e046ea7..bf79a0b 100644 --- a/src/string/strchr.c +++ b/src/string/strchr.c @@ -151,6 +151,6 @@ char* strrchr(const char* string, int c) if (*string == c) r = string; else if (!*string++) - return r; + return c ? r : (string - 1); } -- cgit v1.2.3-70-g09d2