From 5d3a382eb79f4d48635320c0136788bbffa59058 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 14 Jan 2025 14:34:29 -0800
Subject: [PATCH] Fixed potentially overlapping memcpy() to use memmove()
(cherry picked from commit 91b76f5c297bcf21463852d02b0a6b2a73e5db59)
---
src/joystick/hidapi/SDL_hidapi_ps4.c | 2 +-
src/joystick/hidapi/SDL_hidapi_ps5.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c
index 30169649e6c8a..fd38dc98a2d90 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps4.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps4.c
@@ -263,7 +263,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
j = -1;
for (i = 0; i < 12; i += 2) {
j += 1;
- SDL_memcpy(&serial[j], &device->serial[i], 2);
+ SDL_memmove(&serial[j], &device->serial[i], 2);
j += 2;
serial[j] = '-';
}
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 5065fc5a08553..159a0e846bf03 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -371,7 +371,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
j = -1;
for (i = 0; i < 12; i += 2) {
j += 1;
- SDL_memcpy(&serial[j], &device->serial[i], 2);
+ SDL_memmove(&serial[j], &device->serial[i], 2);
j += 2;
serial[j] = '-';
}