sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit fc85dc819da6dcc83bc6da0bb01e725256d2977e
parent a1f0426699523809ba50db47829c038ee4b762ab
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 22 Sep 2023 14:18:14 +0200

xargs: Free argument before substitution

strnsubst() allocates a new array always, indepently of
the number of occurences of the replace string.

Diffstat:
Mxargs.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/xargs.c b/xargs.c @@ -266,9 +266,11 @@ main(int argc, char *argv[]) argsz += arglen + 1; } else { for (j = 1; j < i; j++) { + char *p = cmd[j]; argsz -= strlen(cmd[j]); strnsubst(&cmd[j], replstr, arg, 255); argsz += strlen(cmd[j]); + free(p); } }