1999-01-22 Alexandre Oliva <oliva@dcc.unicamp.br>
+ * 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 <Edouard.Parmelan@France.NCR.COM>
+
* Makefile.am (ltconfig, ltmain.sh, TIMESTAMP): let's not assume
anything about the format of the date, just that it does not
contain `$'
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;
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
#endif
}
if (!file) {
- clean_up_name:
- free(name);
goto clean_up_dir;
}
while (!feof(file)) {
last_error = memory_error;
goto clean_up_vars;
}
+ handle->usage = 0;
if (deplibs && load_deplibs(handle, deplibs)) {
clean_up_handle:
free(handle);
dlname, old_name))
goto clean_up_deplibs;
}
- handle->name = name;
clean_up_vars:
if (dlname)
free(dlname);
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);
last_error = memory_error;
goto clean_up_dir;
}
+ handle->usage = 0;
if (tryall_dlopen(&handle, filename)
&& (dir
|| (find_library(&handle, basename, usr_search_path)
}
#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;
}