diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2019-05-23 20:23:33 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2019-05-23 20:23:33 +0200 |
commit | 4fe419cac3a5732844e5dd9fd52600b054bd0b18 (patch) | |
tree | 0aa6a53912c7eae67e486457f3beb72a8c3242ed | |
parent | a5c0031ec4ac648261553128894e157ee41889cb (diff) | |
download | dlfcn-win32-4fe419cac3a5732844e5dd9fd52600b054bd0b18.tar.gz dlfcn-win32-4fe419cac3a5732844e5dd9fd52600b054bd0b18.tar.bz2 dlfcn-win32-4fe419cac3a5732844e5dd9fd52600b054bd0b18.zip |
Correctly process and indicate error in dlsym() function
Function save_err_str() checks for error by GetLastError() call. So ensure
that last error is always set when error occurs.
-rw-r--r-- | dlfcn.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -362,10 +362,17 @@ void *dlsym( void *handle, const char *name ) | |||
362 | size_t sLen; | 362 | size_t sLen; |
363 | sLen = VirtualQueryEx( hCurrentProc, _ReturnAddress(), &info, sizeof( info ) ); | 363 | sLen = VirtualQueryEx( hCurrentProc, _ReturnAddress(), &info, sizeof( info ) ); |
364 | if( sLen != sizeof( info ) ) | 364 | if( sLen != sizeof( info ) ) |
365 | { | ||
366 | if( sLen != 0 ) | ||
367 | SetLastError( ERROR_INVALID_PARAMETER ); | ||
365 | goto end; | 368 | goto end; |
369 | } | ||
366 | hCaller = (HMODULE) info.AllocationBase; | 370 | hCaller = (HMODULE) info.AllocationBase; |
367 | if(!hCaller) | 371 | if( !hCaller ) |
372 | { | ||
373 | SetLastError( ERROR_INVALID_PARAMETER ); | ||
368 | goto end; | 374 | goto end; |
375 | } | ||
369 | } | 376 | } |
370 | 377 | ||
371 | if( handle != RTLD_NEXT ) | 378 | if( handle != RTLD_NEXT ) |
@@ -423,6 +430,8 @@ void *dlsym( void *handle, const char *name ) | |||
423 | end: | 430 | end: |
424 | if( symbol == NULL ) | 431 | if( symbol == NULL ) |
425 | { | 432 | { |
433 | if( GetLastError() == 0 ) | ||
434 | SetLastError( ERROR_PROC_NOT_FOUND ); | ||
426 | save_err_str( name ); | 435 | save_err_str( name ); |
427 | } | 436 | } |
428 | 437 | ||