From 6fffb233f17983892f1f0fd43905039d6f33a63b Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Fri, 22 Jan 1999 17:08:26 +0000 Subject: [PATCH] * libltdl/ltdl.c (lt_dlopen): if we're reusing a previously opened handle, don't reset its name nor add it to the list, and free the name we have allocated Reported by Edouard G. Parmelan --- ChangeLog | 5 +++++ libltdl/ltdl.c | 23 +++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49727012b..cf529f6f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 1999-01-22 Alexandre Oliva + * libltdl/ltdl.c (lt_dlopen): if we're reusing a previously opened + handle, don't reset its name nor add it to the list, and free the + name we have allocated + Reported by Edouard G. Parmelan + * Makefile.am (ltconfig, ltmain.sh, TIMESTAMP): let's not assume anything about the format of the date, just that it does not contain `$' diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 43b47bbb3..a655cd484 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -981,7 +981,7 @@ lt_dlopen (filename) const char *filename; { lt_dlhandle handle = 0; - char *dir = 0; + char *dir = 0, *name = 0; const char *basename, *ext; const char *saved_error = last_error; @@ -1004,7 +1004,6 @@ lt_dlopen (filename) char *dlname = 0, *old_name = 0; char *libdir = 0, *deplibs = 0; char tmp[LTDL_FILENAME_MAX]; - char *name; FILE *file; int i; /* if we can't find the installed flag, it is probably an @@ -1044,8 +1043,6 @@ lt_dlopen (filename) #endif } if (!file) { - clean_up_name: - free(name); goto clean_up_dir; } while (!feof(file)) { @@ -1086,6 +1083,7 @@ lt_dlopen (filename) last_error = memory_error; goto clean_up_vars; } + handle->usage = 0; if (deplibs && load_deplibs(handle, deplibs)) { clean_up_handle: free(handle); @@ -1110,7 +1108,6 @@ lt_dlopen (filename) dlname, old_name)) goto clean_up_deplibs; } - handle->name = name; clean_up_vars: if (dlname) free(dlname); @@ -1121,7 +1118,7 @@ lt_dlopen (filename) if (deplibs) free(deplibs); if (!handle) - goto clean_up_name; + goto clean_up_dir; } else { /* try to append libtool library extension */ char *newfilename = malloc(strlen(filename)+4); @@ -1142,6 +1139,7 @@ lt_dlopen (filename) last_error = memory_error; goto clean_up_dir; } + handle->usage = 0; if (tryall_dlopen(&handle, filename) && (dir || (find_library(&handle, basename, usr_search_path) @@ -1181,16 +1179,21 @@ lt_dlopen (filename) } #endif } - handle->name = 0; } - handle->usage = 1; - handle->next = handles; - handles = handle; + if (!handle->usage) { + handle->usage = 1; + handle->next = handles; + handles = handle; + handle->name = name; + name = 0; + } restore_error: last_error = saved_error; clean_up_dir: if (dir) free(dir); + if (name) + free(name); return handle; } -- 2.47.3