]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/lt_dlloader.c (lt_dlloader_add): Handle malloc failure
authorGary V. Vaughan <gary@gnu.org>
Wed, 1 Sep 2004 17:32:09 +0000 (17:32 +0000)
committerGary V. Vaughan <gary@gnu.org>
Wed, 1 Sep 2004 17:32:09 +0000 (17:32 +0000)
from slist_new.
* libltdl/ltdl.c (loader_init): Trust lt_dlloader_add(), don't
overwrite its error type, and simplify.
Reported by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>

ChangeLog
libltdl/lt_dlloader.c
libltdl/ltdl.c

index edf31703cf242b68cc1b0db24be466f00ece4e6d..91e5b0d7b94371538d7889f94d896bf013d75673 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2004-09-01  Gary V. Vaughan  <gary@gnu.org>
+
+       * libltdl/lt_dlloader.c (lt_dlloader_add): Handle malloc failure
+       from slist_new.
+       * libltdl/ltdl.c (loader_init): Trust lt_dlloader_add(), don't
+       overwrite its error type, and simplify.
+       Reported by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
 2004-09-01  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * libltdl/slist.c (slist_new): Handle malloc failure gracefully.
index 8487747c19b2099ea030f7118281f5b62f6049e9..1700cc019652bf00813f1a22f9481146e3ab8359 100644 (file)
@@ -59,29 +59,37 @@ loader_cmp (const SList *node, const void *userdata)
 int
 lt_dlloader_add (const lt_dlvtable *vtable)
 {
-  if ((vtable == 0)    /* diagnose null parameters */
+  SList *list;
+
+  if ((vtable == 0)    /* diagnose invalid vtable fields */
       || (vtable->module_open == 0)
       || (vtable->module_close == 0)
-      || (vtable->find_sym == 0))
+      || (vtable->find_sym == 0)
+      || ((vtable->priority != LT_DLLOADER_PREPEND) &&
+         (vtable->priority != LT_DLLOADER_APPEND)))
     {
       LT__SETERROR (INVALID_LOADER);
       return RETURN_FAILURE;
     }
 
-  switch (vtable->priority)
+  list = slist_new (vtable);
+  if (!list)
     {
-    case LT_DLLOADER_PREPEND:
-      loaders = slist_cons (slist_new (vtable), loaders);
-      break;
-
-    case LT_DLLOADER_APPEND:
-      loaders = slist_concat (loaders, slist_new (vtable));
-      break;
+      (*lt__alloc_die) ();
 
-    default:
-      LT__SETERROR (INVALID_LOADER);
+      /* Let the caller know something went wrong if lt__alloc_die
+        doesn't abort.  */
       return RETURN_FAILURE;
-      /*NOTREACHED*/
+    }
+
+  if (vtable->priority == LT_DLLOADER_PREPEND)
+    {
+      loaders = slist_cons (list, loaders);
+    }
+  else
+    {
+      assert (vtable->priority == LT_DLLOADER_APPEND);
+      loaders = slist_concat (loaders, list);
     }
 
   return RETURN_SUCCESS;
index 9c4215b10ac42a41306f7020981004f9885e6d32..27273595cb8dac4b03aa797d0cf6944eacfb2893 100644 (file)
@@ -167,20 +167,10 @@ loader_init (lt_get_vtable *vtable_func, lt_user_data data)
       vtable = (*vtable_func) (data);
     }
 
-  if (!vtable)
-    {
-      LT__SETERROR (INVALID_LOADER);
-      ++errors;
-    }
+  /* lt_dlloader_add will LT__SETERROR if it fails.  */
+  errors += lt_dlloader_add (vtable);
 
-  if (!errors)
-    {
-      if (lt_dlloader_add (vtable))
-       {
-         LT__SETERROR (DLOPEN_NOT_SUPPORTED);
-         ++errors;
-       }
-    }
+  assert (errors || vtable);
 
   if ((!errors) && vtable->dlloader_init)
     {