mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-09 02:29:07 +08:00
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:
parent
f05323bef0
commit
5e145c08ba
@ -51,9 +51,9 @@ small:
|
|||||||
const long *lb = (const long *)b;
|
const long *lb = (const long *)b;
|
||||||
long *lend = (long *)((uintptr_t)end & ~msk);
|
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 b0 = *lb++;
|
||||||
long b1 = *lb++;
|
long b1 = *lb++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user