aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Traversaro <pegua1@gmail.com>2017-05-04 13:12:01 +0200
committerGitHub <noreply@github.com>2017-05-04 13:12:01 +0200
commit4960605816a3ae1bc2de3e357529ea955e256601 (patch)
tree0bfa491358554c77d14225b4d441323bbad9a8e0
parent18195b170b636b10d30b4073f7bdecf6a331fc9d (diff)
parent5bcd8c53987200107b28a76f4ef38d805e0f6d25 (diff)
downloaddlfcn-win32-4960605816a3ae1bc2de3e357529ea955e256601.tar.gz
dlfcn-win32-4960605816a3ae1bc2de3e357529ea955e256601.tar.bz2
dlfcn-win32-4960605816a3ae1bc2de3e357529ea955e256601.zip
Merge pull request #36 from dlfcn-win32/fix-dlerror
Fix bug in dlerror second consecutive call
-rw-r--r--dlfcn.c6
-rw-r--r--test.c15
2 files changed, 21 insertions, 0 deletions
diff --git a/dlfcn.c b/dlfcn.c
index 4367bd7..a91e963 100644
--- a/dlfcn.c
+++ b/dlfcn.c
@@ -431,6 +431,12 @@ end:
431char *dlerror( void ) 431char *dlerror( void )
432{ 432{
433 char *error_pointer = dlerror_buffer; 433 char *error_pointer = dlerror_buffer;
434
435 /* If this is the second consecutive call to dlerror, return NULL */
436 if (current_error == NULL)
437 {
438 return NULL;
439 }
434 440
435#ifdef UNICODE 441#ifdef UNICODE
436 errno_t err = 0; 442 errno_t err = 0;
diff --git a/test.c b/test.c
index 14523ad..ba440da 100644
--- a/test.c
+++ b/test.c
@@ -304,6 +304,21 @@ int main()
304 error = dlerror( ); 304 error = dlerror( );
305 printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n", 305 printf( "SUCCESS\tCould not get nonexistent symbol from global handle: %s\n",
306 error ? error : "" ); 306 error ? error : "" );
307
308 /* Test that the second call to dlerror() returns null as in the specs
309 See https://github.com/dlfcn-win32/dlfcn-win32/issues/34 */
310 error = dlerror( );
311 if( error == NULL )
312 {
313 printf( "SUCCESS\tSecond consecutive call to dlerror returned NULL\n");
314 }
315 else
316 {
317 printf( "ERROR\tSecond consecutive call to dlerror returned a non-NULL pointer: %p\n", error );
318 CLOSE_LIB;
319 CLOSE_GLOBAL;
320 RETURN_ERROR;
321 }
307 } 322 }
308 323
309 function = dlsym(global, "fwrite"); 324 function = dlsym(global, "fwrite");