| Summary: | Extra variable in SDL_LoadFunction() | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Tolga Dalman <tdalman> |
| Component: | loadso | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 1.2 | ||
| Hardware: | x86 | ||
| OS: | All | ||
Hmm, this looks like it was meant to handle platforms that need a '_' prepended to the function's symbol, but it's not filled in properly. Probably shouldn't be removed, but it's definitely a bug. --ryan. In that case, I propose the following patch, which disables that particular code
with a macro:
Index: SDL_sysloadso.c
===================================================================
--- SDL_sysloadso.c (revision 2905)
+++ SDL_sysloadso.c (working copy)
@@ -46,11 +46,15 @@
void *symbol = dlsym(handle, name);
if ( symbol == NULL ) {
size_t len = 1+SDL_strlen(name)+1;
+#ifdef DLOPEN_NEED_UNDERSCORE
char *_name = SDL_stack_alloc(char, len);
_name[0] = '_';
SDL_strlcpy(&_name[1], name, len);
+#endif
symbol = dlsym(handle, name);
+#ifdef DLOPEN_NEED_UNDERSCORE
SDL_stack_free(_name);
+#endif
if ( symbol == NULL ) {
SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror());
}
Fixed in svn revision #2951 for 1.2 branch and #2952 for 1.3 branch. --ryan. |
I don't see any sense in using the variable _name, nor copying name into _name. Here is a patch: =================================================================== --- SDL_sysloadso.c (revision 2609) +++ SDL_sysloadso.c (working copy) @@ -46,11 +46,7 @@ void *symbol = dlsym(handle, name); if ( symbol == NULL ) { size_t len = 1+SDL_strlen(name)+1; - char *_name = SDL_stack_alloc(char, len); - _name[0] = '_'; - SDL_strlcpy(&_name[1], name, len); symbol = dlsym(handle, name); - SDL_stack_free(_name); if ( symbol == NULL ) { SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror()); }