about summary refs log tree commit diff stats
path: root/src/wrapped
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-04-25 14:03:28 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-04-25 14:03:28 +0200
commit549c42ac1913c06547abcc99c8ebb6dc745fe4e4 (patch)
treebb469a406f9e457ad231acf5a747f715e8985726 /src/wrapped
parent6bfeb156551ce98d4feafb6fe764bbe4fd1cab03 (diff)
downloadbox64-549c42ac1913c06547abcc99c8ebb6dc745fe4e4.tar.gz
box64-549c42ac1913c06547abcc99c8ebb6dc745fe4e4.zip
Improved/fixed (agaaaaain) Load/Unload of library (might help #740 &nd #742)
Diffstat (limited to 'src/wrapped')
-rwxr-xr-xsrc/wrapped/wrappedlibdl.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/wrapped/wrappedlibdl.c b/src/wrapped/wrappedlibdl.c
index 9267ee4b..34df9340 100755
--- a/src/wrapped/wrappedlibdl.c
+++ b/src/wrapped/wrappedlibdl.c
@@ -173,19 +173,17 @@ void* my_dlopen(x64emu_t* emu, void *filename, int flag)
         // Then open the lib
         my_context->deferredInit = 1;
         int bindnow = (!box64_musl && (flag&0x2))?1:0;
-        needed_libs_t tmp = {0};
-        char* names[] = {rfilename};
-        library_t* libs[] = { NULL };
-        tmp.size = tmp.cap = 1;
-        tmp.names = names;
-        tmp.libs = libs;
-        if(AddNeededLib(NULL, is_local, bindnow, &tmp, my_context, emu)) {
+        needed_libs_t *tmp = new_neededlib(1);
+        tmp->names[0] = rfilename;
+        if(AddNeededLib(NULL, is_local, bindnow, tmp, my_context, emu)) {
             printf_dlsym(strchr(rfilename,'/')?LOG_DEBUG:LOG_INFO, "Warning: Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag);
             if(!dl->last_error)
                 dl->last_error = box_malloc(129);
             snprintf(dl->last_error, 129, "Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag);
+            RemoveNeededLib(NULL, is_local, tmp, my_context, emu);
             return NULL;
         }
+        free_neededlib(tmp);
         lib = GetLibInternal(rfilename);
         RunDeferredElfInit(emu);
     } else {