You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ext/gettext/gettext.c: fudge bindtextdomain() return value on musl
According to POSIX, bindtextdomain() returns "the implementation-
defined default directory pathname used by the gettext family of
functions" when its second parameter is NULL (i.e. when you are
querying the directory corresponding to some text domain and that
directory has not yet been set). But musl does not do this: when no
directory has been set, it consults an environment variable (that
itself may be unset), and there is no default:
if (!libc.secure) path = getenv("MUSL_LOCPATH");
/* FIXME: add a default path? */
Worse, the musl bindtextdomain(..., NULL) query always returns NULL,
even when MUSL_LOCPATH is set. This is segfaulting bindtextdomain() in
PHP because it tries to RETURN_STRING on the NULL pointer that the C
function returns.
To work around this, we check for a NULL return from the C function,
and then try to return the value of MUSL_LOCPATH. (This still isn't
perfect, because MUSL_LOCPATH can contain multiple paths, but at least
it's a string.) If MUSL_LOCPATH is unset, we RETURN_FALSE to indicate
failure (there's really no default) rather than segfaulting.
This partially addresses GH #13696
0 commit comments