fixes string replace function in case replmax is 0

Sun, 29 Dec 2019 19:45:00 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 29 Dec 2019 19:45:00 +0100
changeset 383
db4c6b94939b
parent 382
d746888af4e5
child 384
9b81a555c059

fixes string replace function in case replmax is 0

src/string.c file | annotate | diff | comparison | revisions
--- a/src/string.c	Sun Dec 29 16:04:34 2019 +0100
+++ b/src/string.c	Sun Dec 29 19:45:00 2019 +0100
@@ -682,7 +682,7 @@
 sstr_t scstrreplacen_a(UcxAllocator *allocator, scstr_t str,
                      scstr_t pattern, scstr_t replacement, size_t replmax) {
 
-    if (pattern.length == 0 || pattern.length > str.length)
+    if (pattern.length == 0 || pattern.length > str.length || replmax == 0)
         return sstrdup(str);
 
     /* Compute expected buffer length */

mercurial