diff options
author | Rob Landley <rob@landley.net> | 2020-01-01 11:57:06 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-01-01 11:57:06 -0600 |
commit | d405b8cd57708b5b097b57e4e44cb849dfd7b399 (patch) | |
tree | b4d4ec0dc05034b993b2fff63c7ed273ac969f25 /toys | |
parent | b4ea29ef4f33345968df89dc8cbba80a75ffda59 (diff) | |
download | toybox-d405b8cd57708b5b097b57e4e44cb849dfd7b399.tar.gz |
If allocation update is done in blocks, initial allocation has to populate
a full block.
Diffstat (limited to 'toys')
-rw-r--r-- | toys/pending/sh.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/toys/pending/sh.c b/toys/pending/sh.c index d575791f..300ad24b 100644 --- a/toys/pending/sh.c +++ b/toys/pending/sh.c @@ -287,10 +287,11 @@ static char *expand_one_arg(char *new, unsigned flags, struct string_list **del) memset(&arg, 0, sizeof(arg)); expand_arg(&arg, new, flags, 0); - if (arg.c == 1) s = *arg.v; - else for (i = 0; i < arg.c; i++) free(arg.v[i]); + if (arg.c == 1) { + s = *arg.v; + if (del && s != new) dlist_add((void *)del, s); + } else for (i = 0; i < arg.c; i++) free(arg.v[i]); free(arg.v); - if (del && s != new) dlist_add((void *)del, s); return s; } @@ -722,7 +723,7 @@ if (BUGBUG) { int i; dprintf(255, "envlen=%d arg->c=%d run=", envlen, arg->c); f if (envlen) { kk = 0; if (environ) while (environ[kk]) kk++; - if (kk) env = xmemdup(environ, sizeof(char *)*(kk+1)); + if (kk) env = xmemdup(environ, sizeof(char *)*(kk+33)); for (j = 0; j<envlen; j++) { sss = expand_one_arg(arg->v[j], NO_PATH|NO_SPLIT, &pp->delete); for (ll = 0; ll<kk; ll++) { @@ -1370,8 +1371,7 @@ if (BUGBUG) dprintf(255, "type=%d %s %s\n", pl->type, pl->arg->v[0], pl->arg->v[ pl = blk->end; // TODO collate end_block logic - // if ending a block, free, cleanup redirects, and pop stack. - + // if ending a block, free, cleanup redirects and pop stack. llist_traverse(blk->fdelete, free); unredirect(blk->urd); if (*pipes) close(*pipes); |