Skip to content

Commit 49dd24e

Browse files
committed
Fixed potentially overlapping memcpy() to use memmove()
1 parent 191a641 commit 49dd24e

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/core/android/SDL_android.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ static int FindLifecycleEvent(SDL_AndroidLifecycleEvent event)
883883
static void RemoveLifecycleEvent(int index)
884884
{
885885
if (index < Android_NumLifecycleEvents - 1) {
886-
SDL_memcpy(&Android_LifecycleEvents[index], &Android_LifecycleEvents[index+1], (Android_NumLifecycleEvents - index - 1) * sizeof(Android_LifecycleEvents[index]));
886+
SDL_memmove(&Android_LifecycleEvents[index], &Android_LifecycleEvents[index+1], (Android_NumLifecycleEvents - index - 1) * sizeof(Android_LifecycleEvents[index]));
887887
}
888888
--Android_NumLifecycleEvents;
889889
}

src/joystick/hidapi/SDL_hidapi_ps4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
298298
j = -1;
299299
for (i = 0; i < 12; i += 2) {
300300
j += 1;
301-
SDL_memcpy(&serial[j], &device->serial[i], 2);
301+
SDL_memmove(&serial[j], &device->serial[i], 2);
302302
j += 2;
303303
serial[j] = '-';
304304
}

src/joystick/hidapi/SDL_hidapi_ps5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
387387
j = -1;
388388
for (i = 0; i < 12; i += 2) {
389389
j += 1;
390-
SDL_memcpy(&serial[j], &device->serial[i], 2);
390+
SDL_memmove(&serial[j], &device->serial[i], 2);
391391
j += 2;
392392
serial[j] = '-';
393393
}

src/test/SDL_test_font.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char
123123
if (newline) {
124124
if (textwin->current == textwin->numlines - 1) {
125125
SDL_free(textwin->lines[0]);
126-
SDL_memcpy(&textwin->lines[0], &textwin->lines[1], (textwin->numlines - 1) * sizeof(textwin->lines[1]));
126+
SDL_memmove(&textwin->lines[0], &textwin->lines[1], (textwin->numlines - 1) * sizeof(textwin->lines[1]));
127127
textwin->lines[textwin->current] = NULL;
128128
} else {
129129
++textwin->current;

0 commit comments

Comments
 (0)