浏览代码

Fixed potentially overlapping memcpy() to use memmove()

Sam Lantinga 8 月之前
父节点
当前提交
91b76f5c29
共有 2 个文件被更改,包括 2 次插入2 次删除
  1. 1 1
      src/joystick/hidapi/SDL_hidapi_ps4.c
  2. 1 1
      src/joystick/hidapi/SDL_hidapi_ps5.c

+ 1 - 1
src/joystick/hidapi/SDL_hidapi_ps4.c

@@ -263,7 +263,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
         j = -1;
         j = -1;
         for (i = 0; i < 12; i += 2) {
         for (i = 0; i < 12; i += 2) {
             j += 1;
             j += 1;
-            SDL_memcpy(&serial[j], &device->serial[i], 2);
+            SDL_memmove(&serial[j], &device->serial[i], 2);
             j += 2;
             j += 2;
             serial[j] = '-';
             serial[j] = '-';
         }
         }

+ 1 - 1
src/joystick/hidapi/SDL_hidapi_ps5.c

@@ -371,7 +371,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
         j = -1;
         j = -1;
         for (i = 0; i < 12; i += 2) {
         for (i = 0; i < 12; i += 2) {
             j += 1;
             j += 1;
-            SDL_memcpy(&serial[j], &device->serial[i], 2);
+            SDL_memmove(&serial[j], &device->serial[i], 2);
             j += 2;
             j += 2;
             serial[j] = '-';
             serial[j] = '-';
         }
         }