Fix bug zero-terminating truncated string

This commit is contained in:
Justin Ethier 2022-06-07 23:00:12 -04:00
parent 4091dc4662
commit 92ec4a0b7f
2 changed files with 6 additions and 3 deletions

View file

@ -2537,7 +2537,7 @@ void bignum2string(void *data, object cont, bignum2_type *bn, int radix)
i = str_length - (index - buf);
s->len = s->num_cp = i;
memmove(buf, index, i);
buf[str_length-1] = '\0';
s->str[i] = '\0';
}
}
return_closcall1(data, cont, s);

View file

@ -17,9 +17,12 @@
bignum2string(data, k, bn, obj_obj2int(radix));
")
(write
(map
(lambda (row)
(write row)
(newline))
(list
(test-larger-bn 0 #x0FFF0001 10) ;; TODO: why is this not writing the correct number?
(test-larger-bn 0 #x0FFF0001 10)
(test-bn #x0FFF0001 10)
(test-bn -10 10)