Commit 70c5c20a7c4b23720fbba8be4508a002a0f7c28a

Pali Rohár 2020-02-19T22:39:29

Show "(null)" in error message when passed filname to dlopen() was NULL and error occurred It does not make sense to pass file variable (which is NULL) to function save_err_ptr_str() which converts its argument to string. We can call directly save_err_str() with string value. Also it is highly unexpected that GetModuleHandle(NULL) call fails.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/dlfcn.c b/dlfcn.c
index e13c631..2497a39 100644
--- a/dlfcn.c
+++ b/dlfcn.c
@@ -233,7 +233,7 @@ void *dlopen( const char *file, int mode )
         hModule = GetModuleHandle( NULL );
 
         if( !hModule )
-            save_err_ptr_str( file );
+            save_err_str( "(null)" );
     }
     else
     {