* src/autofit/ft-hb.c: Fix usage of RTLD_DEFAULT.

Using `RTLD_DEFAULT` we see whether the process already has HarfBuzz linked
in, and reuse it.  If this symbol is not defined it is tempting to use
`RTLD_GLOBAL` instead, which would make the library available to the whole
process.  However, without `RTLD_DEFAULT`, we would risk loading a second
HarfBuzz library, and if the linker mixes them up, probably giving symbols
from the new library to other clients, we might get into trouble.  For this
reason, we do not pass `RTLD_GLOBAL` to `dlopen`; the default is
`RTLD_LOCAL`, and the rest of the process won't see the loaded HarfBuzz and
hopefully all be happy.
This commit is contained in:
Behdad Esfahbod 2025-06-03 07:56:13 +02:00 committed by Werner Lemberg
parent 5a07f41d0e
commit 43ec023e1a

View file

@ -45,6 +45,7 @@
#else /* !_WIN32 */
# define _GNU_SOURCE 1 /* for RTLD_DEFAULT */
# include <dlfcn.h>
/* The GCC pragma suppresses the warning "ISO C forbids */
@ -96,8 +97,11 @@
#else /* !_WIN32 */
lib = RTLD_DEFAULT;
# ifdef RTLD_DEFAULT
lib = RTLD_DEFAULT;
version_atleast = DLSYM( lib, hb_version_atleast );
# endif
if ( !version_atleast )
{
/* Load the HarfBuzz library.