Found the issue. strcopy is copying the string past the null character. On Thu, Mar 21, 2019 at 3:54 PM enh <[email protected]> wrote:
> commit 1a3c65c868b676c86073025465f57116d0e91881 broke bc... there's no > output any more from, say, `1+1`... > > i had a look through the diff, but it wasn't obvious what the active > ingredient was. the tests still pass, and that seems legit --- only > input stdin is broken. files work fine (with or without -l). >
From 474fbabeed9f01a80965b5e0f20fa7df2dcbfe43 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg <[email protected]> Date: Mon, 25 Mar 2019 16:08:07 -0700 Subject: [PATCH] Fix bc_vec_concat BcVec contains the null at the end, so v->len is greater than strlen(v->v) by one. --- toys/pending/bc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toys/pending/bc.c b/toys/pending/bc.c index 142c0ce2..bb5d86cb 100644 --- a/toys/pending/bc.c +++ b/toys/pending/bc.c @@ -952,8 +952,8 @@ void bc_vec_concat(BcVec *v, char *str) { if (!v->len) bc_vec_pushByte(v, '\0'); len = strlen(str); - bc_vec_grow(v, len+1); - strcpy(v->v+v->len, str); + bc_vec_grow(v, len); + strcpy(v->v+v->len-1, str); v->len += len; } -- 2.21.0.392.gf8f6787159e-goog
_______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
