]> git.sesse.net Git - vlc/blobdiff - bin/override.c
Block setlocale()
[vlc] / bin / override.c
index 2e8919925b02828a00cb47d8b014e39589c28eb9..60bee0ce3eebfa21a527a5359bbc9a82da79f087 100644 (file)
@@ -89,7 +89,8 @@ static void *getsym (const char *name)
     void *sym = dlsym (RTLD_NEXT, name);
     if (sym == NULL)
     {
-        fprintf (stderr, "Cannot resolve symbol %s!\n", name);
+        fprintf (stderr, "Cannot resolve symbol %s: %s\n", name,
+                 dlerror ());
         abort ();
     }
     return sym;
@@ -195,6 +196,24 @@ int sigaction (int signum, const struct sigaction *act, struct sigaction *old)
 }
 
 
+/*** Locales ***
+ * setlocale() is not thread-safe and has a tendency to crash other threads as
+ * quite many libc and libintl calls depend on the locale.
+ * Use uselocale() instead for thread-safety.
+ */
+#include <locale.h>
+
+char *setlocale (int cat, const char *locale)
+{
+    if (override && locale != NULL)
+    {
+        LOG("Blocked", "%d, \"%s\"", cat, locale);
+        return NULL;
+    }
+    return CALL(setlocale, cat, locale);
+}
+
+
 /*** Xlib ****/
 #ifdef HAVE_X11_XLIB_H
 # include <X11/Xlib.h>