utils: fix cstring_rfind
authorNiki Roo <niki@nikiroo.be>
Thu, 3 Mar 2022 19:41:01 +0000 (20:41 +0100)
committerNiki Roo <niki@nikiroo.be>
Thu, 3 Mar 2022 19:41:01 +0000 (20:41 +0100)
src/utils/cstring.c

index 56a79fe9845303186337c5145ce46caab36930b1..d5015375d9ad2c2e71117d2bff53116aec0d1a2f 100644 (file)
@@ -422,7 +422,7 @@ long cstring_rfind(char self[], const char find[], long rstart_index) {
        size_t sz_needle = strlen(find);
 
        if (rstart_index <= 0)
-               rstart_index = (sz - 1);
+               rstart_index += (sz - 1);
 
        if (sz > rstart_index && sz_needle <= sz) {
                for (size_t i = rstart_index;; i--) {