commit 22f110db281176b477ec8508b077750ab3449f97
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Fri Sep 22 11:24:37 2023 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Fri Sep 22 11:44:58 2023 +0200

    libutil: Remove free() from strnsub()
    
    The free() was added in the wrong assumption that xargs was not
    freeing the argument in the position replaced, but it actually
    does it.
    
    Also, removing the call to free() makes more general the function.

diff --git a/libutil/strnsubst.c b/libutil/strnsubst.c
index 9ea6013..2da54ab 100644
--- a/libutil/strnsubst.c
+++ b/libutil/strnsubst.c
@@ -56,7 +56,6 @@ strnsubst(char **str, const char *match, const char *replstr, 
size_t maxsize)
        }
        strlcpy(s2 + s2len, s1, maxsize - s2len);
 done:
-       free(*str);
        *str = s2;
        return;
 }

Reply via email to