]> git.sesse.net Git - vlc/commitdiff
Block setlocale()
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 12 Apr 2010 18:25:59 +0000 (21:25 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 12 Apr 2010 18:25:59 +0000 (21:25 +0300)
This has already caused some problems (e.g. live555)

bin/override.c

index 964bc21d8794fce1db8eebe80ee58330ad885685..60bee0ce3eebfa21a527a5359bbc9a82da79f087 100644 (file)
@@ -196,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>