]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/ltdl.c (lt_dlopen): if we're reusing a previously opened
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Fri, 22 Jan 1999 17:08:26 +0000 (17:08 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Fri, 22 Jan 1999 17:08:26 +0000 (17:08 +0000)
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>

ChangeLog
libltdl/ltdl.c

index 49727012bf75345074685d7f60a6aa2d1ff19ff6..cf529f6f906901defd6529ff7d6f54563ef78e99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 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 `$'
index 43b47bbb391553b05ad5f1944a5706f765ec8ffb..a655cd484195c639f72bf1fc84879a9020488d8d 100644 (file)
@@ -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;
 }