From aeeac9ca5490d7d90fe061ab72da446c01ddf746 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 27 May 2015 15:54:47 -0400 Subject: 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. --- src/locale/freelocale.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/locale/freelocale.c') 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); -- cgit 1.4.1