libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new memleaks in libltdl


From: Ralf Wildenhues
Subject: Re: new memleaks in libltdl
Date: Sun, 1 Jul 2007 08:12:42 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

* Ralf Wildenhues wrote on Sun, Jun 24, 2007 at 01:26:10PM CEST:
> While reviewing Gary's 330 patch, I noticed that the patch that
> introduced lt_dladvise also introduced some memleaks:
> - advise_taken in tryall_dlopen is malloced several times,
>   unnecessarily, and not freed in each code path.  AFAICS the code can
>   be greatly simplified by dropping advise_taken and changing the third
>   parameter of lt_dladvise to be of type lt__advise *.  There are no
>   memory or ownership transfers needed here.

I've applied this patch to fix the above leak.

Cheers,
Ralf

2007-07-01  Ralf Wildenhues  <address@hidden>

        * libltdl/ltdl.c (tryall_dlopen): Rename argument to have typed
        alias of `advise' instead of allocating a copy.  Fixes memleak.

Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.251
diff -u -r1.251 ltdl.c
--- libltdl/ltdl.c      24 Jun 2007 20:46:46 -0000      1.251
+++ libltdl/ltdl.c      1 Jul 2007 06:09:51 -0000
@@ -120,7 +120,7 @@
                                       lt_dladvise advise);
 static int     tryall_dlopen         (lt_dlhandle *handle,
                                       const char *filename,
-                                      lt_dladvise advise,
+                                      lt_dladvise padvise,
                                       const lt_dlvtable *vtable);
 static int     unload_deplibs        (lt_dlhandle handle);
 static lt__advise *advise_dup        (lt__advise *advise);
@@ -342,11 +342,12 @@
    the dlhandle is stored at the address given in PHANDLE.  */
 static int
 tryall_dlopen (lt_dlhandle *phandle, const char *filename,
-              lt_dladvise advise, const lt_dlvtable *vtable)
+              lt_dladvise padvise, const lt_dlvtable *vtable)
 {
   lt__handle * handle          = (lt__handle *) handles;
   const char * saved_error     = 0;
   int          errors          = 0;
+  lt__advise *  advise         = (lt__advise *) padvise;
 
 #ifdef LT_DEBUG_LOADERS
   fprintf (stderr, "tryall_dlopen (%s, %s)\n",
@@ -407,11 +408,6 @@
 
     do
       {
-       lt__advise *advise_taken = 0;
-
-       if (advise)
-         advise_taken = advise_dup ((lt__advise *) advise);
-
        if (vtable)
          loader_vtable = vtable;
        else
@@ -423,7 +419,7 @@
                 filename ? filename : "(null)");
 #endif
        handle->module = (*loader_vtable->module_open) 
(loader_vtable->dlloader_data,
-                                                       filename, advise_taken);
+                                                       filename, advise);
 #ifdef LT_DEBUG_LOADERS
        fprintf (stderr, "  Result: %s\n",
                 handle->module ? "Success" : "Failed");
@@ -431,16 +427,14 @@
 
        if (handle->module != 0)
          {
-           if (advise_taken)
+           if (advise)
              {
-               handle->info.is_resident  = advise_taken->is_resident;
-               handle->info.is_symglobal = advise_taken->is_symglobal;
-               handle->info.is_symlocal  = advise_taken->is_symlocal;
+               handle->info.is_resident  = advise->is_resident;
+               handle->info.is_symglobal = advise->is_symglobal;
+               handle->info.is_symlocal  = advise->is_symlocal;
              }
            break;
          }
-
-       FREE (advise_taken);
       }
     while (!vtable && (loader = lt_dlloader_next (loader)));
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]