Allow overlapping regions to be passed to `bytevector-copy!'.

Reported by Dmitry Chestnykh <dmitry@codingrobots.com>.
Fixes <http://debbugs.gnu.org/10070>.

* libguile/bytevectors.c (scm_bytevector_copy_x): Use `memmove', not
  `memcpy'.

* test-suite/tests/bytevectors.test ("2.2 General
  Operations")["bytevector-copy! overlapping"]: New test.

* doc/ref/api-data.texi (Bytevector Manipulation): Mention possible
  overlapping.
This commit is contained in:
Ludovic Courtès 2011-11-20 01:10:58 +01:00
commit 8071964943
3 changed files with 14 additions and 6 deletions

View file

@ -579,9 +579,9 @@ SCM_DEFINE (scm_bytevector_copy_x, "bytevector-copy!", 5, 0, 0,
if (SCM_UNLIKELY (c_target_start + c_len > c_target_len))
scm_out_of_range (FUNC_NAME, target_start);
memcpy (c_target + c_target_start,
c_source + c_source_start,
c_len);
memmove (c_target + c_target_start,
c_source + c_source_start,
c_len);
return SCM_UNSPECIFIED;
}