mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-07 13:16:36 +02:00
using memmove instead of memcpy for potentially overlapping bignum copies
This commit is contained in:
parent
47a1c61117
commit
998951cab0
1 changed files with 3 additions and 3 deletions
|
@ -79,13 +79,13 @@ sexp sexp_copy_bignum (sexp ctx, sexp dst, sexp a, sexp_uint_t len0) {
|
||||||
size = sexp_sizeof(bignum) + len*sizeof(sexp_uint_t);
|
size = sexp_sizeof(bignum) + len*sizeof(sexp_uint_t);
|
||||||
if (! dst || sexp_bignum_length(dst) < len) {
|
if (! dst || sexp_bignum_length(dst) < len) {
|
||||||
dst = sexp_alloc_tagged(ctx, size, SEXP_BIGNUM);
|
dst = sexp_alloc_tagged(ctx, size, SEXP_BIGNUM);
|
||||||
memcpy(dst, a, size);
|
memmove(dst, a, size);
|
||||||
sexp_bignum_length(dst) = len;
|
sexp_bignum_length(dst) = len;
|
||||||
} else {
|
} else {
|
||||||
memset(dst->value.bignum.data, 0,
|
memset(dst->value.bignum.data, 0,
|
||||||
sexp_bignum_length(dst)*sizeof(sexp_uint_t));
|
sexp_bignum_length(dst)*sizeof(sexp_uint_t));
|
||||||
memcpy(dst->value.bignum.data, a->value.bignum.data,
|
memmove(dst->value.bignum.data, a->value.bignum.data,
|
||||||
sexp_bignum_length(a)*sizeof(sexp_uint_t));
|
sexp_bignum_length(a)*sizeof(sexp_uint_t));
|
||||||
}
|
}
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue