Commit b3ba8f40655ce2ac579b3ccd9f81a5cb8817af07

Sam Lantinga 2022-10-23T16:34:55

Merge commit '3d415bc5d61e625189ccca6348ff1b70c469e45c' into main

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/loadso/dlopen/SDL_sysloadso.c b/src/loadso/dlopen/SDL_sysloadso.c
index e5abe85..3b55a6e 100644
--- a/src/loadso/dlopen/SDL_sysloadso.c
+++ b/src/loadso/dlopen/SDL_sysloadso.c
@@ -60,12 +60,12 @@ SDL_LoadFunction(void *handle, const char *name)
 {
     void *symbol = dlsym(handle, name);
     if (symbol == NULL) {
-        /* append an underscore for platforms that need that. */
+        /* prepend an underscore for platforms that need that. */
         SDL_bool isstack;
-        size_t len = 1 + SDL_strlen(name) + 1;
-        char *_name = SDL_small_alloc(char, len, &isstack);
+        size_t len = SDL_strlen(name) + 1;
+        char *_name = SDL_small_alloc(char, len + 1, &isstack);
         _name[0] = '_';
-        SDL_strlcpy(&_name[1], name, len);
+        SDL_memcpy(&_name[1], name, len);
         symbol = dlsym(handle, _name);
         SDL_small_free(_name, isstack);
         if (symbol == NULL) {