From 2bc13d50a3933de850478203808460ec713e2e0a Mon Sep 17 00:00:00 2001 From: Mihai Radu Date: Wed, 7 Dec 2022 15:47:14 +0200 Subject: [PATCH] fix xcrush-divideByZero (when src ==dst) --- libfreerdp/codec/xcrush.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/libfreerdp/codec/xcrush.c b/libfreerdp/codec/xcrush.c index 684cfca6a..e92472178 100644 --- a/libfreerdp/codec/xcrush.c +++ b/libfreerdp/codec/xcrush.c @@ -754,31 +754,10 @@ static int xcrush_generate_output(XCRUSH_CONTEXT* xcrush, BYTE* OutputBuffer, UI static INLINE size_t xcrush_copy_bytes(BYTE* dst, const BYTE* src, size_t num) { - size_t diff, rest, end, a; - WINPR_ASSERT(dst); WINPR_ASSERT(src); - if (src + num < dst || src > dst + num) - { - memcpy(dst, src, num); - } - else - { - // src and dst overlaps - // we should copy the area that doesn't overlap repeatly - diff = (dst > src) ? dst - src : src - dst; - rest = num % diff; - end = num - rest; - for (a = 0; a < end; a += diff) - { - memcpy(&dst[a], &src[a], diff); - } - - if (rest != 0) - memcpy(&dst[end], &src[end], rest); - } - + memmove(dst, src, num); return num; }