[vlc-commits] commit: Block setlocale() ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Mon Apr 12 20:26:40 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Apr 12 21:25:59 2010 +0300| [f0d55dabe9747009d296e251bda7dc2f812bb077] | committer: Rémi Denis-Courmont 

Block setlocale()

This has already caused some problems (e.g. live555)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f0d55dabe9747009d296e251bda7dc2f812bb077
---

 bin/override.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/bin/override.c b/bin/override.c
index 964bc21..60bee0c 100644
--- a/bin/override.c
+++ b/bin/override.c
@@ -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>



More information about the vlc-commits mailing list