riscv: fix integer wraparound in memcpy

This patch fixes a bug in RISC-V's memcpy implementation where an
integer wraparound occurs when src + size < 8 * sizeof(long), causing
the word-sized copy loop to be incorrectly entered.

Signed-off-by: Chih-Mao Chen <cmchen@andestech.com>
This commit is contained in:
PkmX via Newlib 2020-07-24 19:07:45 +08:00 committed by Corinna Vinschen
parent 0947efb859
commit 123b806523
1 changed files with 2 additions and 2 deletions

View File

@ -51,9 +51,9 @@ small:
const long *lb = (const long *)b;
long *lend = (long *)((uintptr_t)end & ~msk);
if (unlikely (la < (lend - 8)))
if (unlikely (lend - la > 8))
{
while (la < (lend - 8))
while (lend - la > 8)
{
long b0 = *lb++;
long b1 = *lb++;