diff options
| -rw-r--r-- | dlfcn.c | 24 |
1 files changed, 9 insertions, 15 deletions
| @@ -129,8 +129,7 @@ static void local_rem( HMODULE hModule ) | |||
| 129 | * the limit. | 129 | * the limit. |
| 130 | */ | 130 | */ |
| 131 | static char error_buffer[65535]; | 131 | static char error_buffer[65535]; |
| 132 | static char *current_error; | 132 | static BOOL error_occurred; |
| 133 | static char dlerror_buffer[65536]; | ||
| 134 | 133 | ||
| 135 | static void save_err_str( const char *str ) | 134 | static void save_err_str( const char *str ) |
| 136 | { | 135 | { |
| @@ -175,7 +174,7 @@ static void save_err_str( const char *str ) | |||
| 175 | error_buffer[pos-2] = '\0'; | 174 | error_buffer[pos-2] = '\0'; |
| 176 | } | 175 | } |
| 177 | 176 | ||
| 178 | current_error = error_buffer; | 177 | error_occurred = TRUE; |
| 179 | } | 178 | } |
| 180 | 179 | ||
| 181 | static void save_err_ptr_str( const void *ptr ) | 180 | static void save_err_ptr_str( const void *ptr ) |
| @@ -214,7 +213,7 @@ void *dlopen( const char *file, int mode ) | |||
| 214 | HMODULE hModule; | 213 | HMODULE hModule; |
| 215 | UINT uMode; | 214 | UINT uMode; |
| 216 | 215 | ||
| 217 | current_error = NULL; | 216 | error_occurred = FALSE; |
| 218 | 217 | ||
| 219 | /* Do not let Windows display the critical-error-handler message box */ | 218 | /* Do not let Windows display the critical-error-handler message box */ |
| 220 | uMode = SetErrorMode( SEM_FAILCRITICALERRORS ); | 219 | uMode = SetErrorMode( SEM_FAILCRITICALERRORS ); |
| @@ -321,7 +320,7 @@ int dlclose( void *handle ) | |||
| 321 | HMODULE hModule = (HMODULE) handle; | 320 | HMODULE hModule = (HMODULE) handle; |
| 322 | BOOL ret; | 321 | BOOL ret; |
| 323 | 322 | ||
| 324 | current_error = NULL; | 323 | error_occurred = FALSE; |
| 325 | 324 | ||
| 326 | ret = FreeLibrary( hModule ); | 325 | ret = FreeLibrary( hModule ); |
| 327 | 326 | ||
| @@ -347,7 +346,8 @@ void *dlsym( void *handle, const char *name ) | |||
| 347 | HMODULE hModule; | 346 | HMODULE hModule; |
| 348 | HANDLE hCurrentProc; | 347 | HANDLE hCurrentProc; |
| 349 | 348 | ||
| 350 | current_error = NULL; | 349 | error_occurred = FALSE; |
| 350 | |||
| 351 | symbol = NULL; | 351 | symbol = NULL; |
| 352 | hCaller = NULL; | 352 | hCaller = NULL; |
| 353 | hModule = GetModuleHandle( NULL ); | 353 | hModule = GetModuleHandle( NULL ); |
| @@ -459,22 +459,16 @@ end: | |||
| 459 | 459 | ||
| 460 | char *dlerror( void ) | 460 | char *dlerror( void ) |
| 461 | { | 461 | { |
| 462 | char *error_pointer = dlerror_buffer; | ||
| 463 | |||
| 464 | /* If this is the second consecutive call to dlerror, return NULL */ | 462 | /* If this is the second consecutive call to dlerror, return NULL */ |
| 465 | if (current_error == NULL) | 463 | if( !error_occurred ) |
| 466 | { | ||
| 467 | return NULL; | 464 | return NULL; |
| 468 | } | ||
| 469 | |||
| 470 | memcpy(error_pointer, current_error, strlen(current_error) + 1); | ||
| 471 | 465 | ||
| 472 | /* POSIX says that invoking dlerror( ) a second time, immediately following | 466 | /* POSIX says that invoking dlerror( ) a second time, immediately following |
| 473 | * a prior invocation, shall result in NULL being returned. | 467 | * a prior invocation, shall result in NULL being returned. |
| 474 | */ | 468 | */ |
| 475 | current_error = NULL; | 469 | error_occurred = FALSE; |
| 476 | 470 | ||
| 477 | return error_pointer; | 471 | return error_buffer; |
| 478 | } | 472 | } |
| 479 | 473 | ||
| 480 | #ifdef SHARED | 474 | #ifdef SHARED |
