]> sourceware.org Git - glibc.git/commitdiff
support: Use dlerror to detect NULL symbols in xdlsym
authorFlorian Weimer <fweimer@redhat.com>
Wed, 6 Feb 2019 15:26:39 +0000 (16:26 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 6 Feb 2019 15:45:25 +0000 (16:45 +0100)
ChangeLog
support/xdlfcn.c

index f2444576f2119c3c7dc6e6e20c22720e12d2779e..66fa654f707226a2951082824844b9f7541062ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-02-06  Florian Weimer  <fweimer@redhat.com>
+
+       * support/xdlfcn.c (xdlopen, xdlclose): Do not call dlerror.
+       (xdlsym): Use dlerror to detect a NULL symbol.
+
 2019-02-06  Florian Weimer  <fweimer@redhat.com>
 
        * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Do not include
index 2f2ac7600389ad91b8c0192c8e32a976d94134c7..b2e5c2113487ca2171e5b045a69996e339c14c21 100644 (file)
@@ -28,22 +28,25 @@ xdlopen (const char *filename, int flags)
   if (dso == NULL)
     FAIL_EXIT1 ("error: dlopen: %s\n", dlerror ());
 
-  /* Clear any errors.  */
-  dlerror ();
-
   return dso;
 }
 
 void *
 xdlsym (void *handle, const char *symbol)
 {
+  /* Clear any pending errors.  */
+  dlerror ();
+
   void *sym = dlsym (handle, symbol);
 
   if (sym == NULL)
-    FAIL_EXIT1 ("error: dlsym: %s\n", dlerror ());
-
-  /* Clear any errors.  */
-  dlerror ();
+    {
+      const char *error = dlerror ();
+      if (error != NULL)
+        FAIL_EXIT1 ("error: dlsym: %s\n", error);
+      /* If there was no error, we found a NULL symbol.  Return the
+         NULL value in this case.  */
+    }
 
   return sym;
 }
@@ -53,7 +56,4 @@ xdlclose (void *handle)
 {
   if (dlclose (handle) != 0)
     FAIL_EXIT1 ("error: dlclose: %s\n", dlerror ());
-
-  /* Clear any errors.  */
-  dlerror ();
 }
This page took 0.061846 seconds and 5 git commands to generate.