summaryrefslogtreecommitdiff
path: root/src/locale/freelocale.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2015-05-27 15:54:47 -0400
committerRich Felker <dalias@aerifal.cx>2015-05-27 15:54:47 -0400
commitaeeac9ca5490d7d90fe061ab72da446c01ddf746 (patch)
tree4f74e2fb42ef8ac46151fe9037c41bb8b5eff52b /src/locale/freelocale.c
parent11858d31aa020df3e7e7dedf49f9870ce12f31cc (diff)
downloadmusl-aeeac9ca5490d7d90fe061ab72da446c01ddf746.tar.gz
implement fail-safe static locales for newlocale
this frees applications which need to make temporary use of the C locale (via uselocale) from the possibility that newlocale might fail. the C.UTF-8 locale is also provided as a static locale. presently they behave the same, but this may change in the future.
Diffstat (limited to 'src/locale/freelocale.c')
-rw-r--r--src/locale/freelocale.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/locale/freelocale.c b/src/locale/freelocale.c
index ee3f029a..c2ae1a31 100644
--- a/src/locale/freelocale.c
+++ b/src/locale/freelocale.c
@@ -2,9 +2,11 @@
#include "locale_impl.h"
#include "libc.h"
+int __loc_is_allocated(locale_t);
+
void freelocale(locale_t l)
{
- free(l);
+ if (__loc_is_allocated(l)) free(l);
}
weak_alias(freelocale, __freelocale);