+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
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;
}
{
if (dlclose (handle) != 0)
FAIL_EXIT1 ("error: dlclose: %s\n", dlerror ());
-
- /* Clear any errors. */
- dlerror ();
}