]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Issue #668: add the option to specify "cmake -DUSELOCALE_NEEDS_FREELOCALE=1" to work...
authorEric Hawicz <erh+git@nimenees.com>
Sun, 30 Jul 2023 17:38:15 +0000 (13:38 -0400)
committerEric Hawicz <erh+git@nimenees.com>
Sun, 30 Jul 2023 17:38:15 +0000 (13:38 -0400)
CMakeLists.txt
cmake/config.h.in
json_tokener.c

index 8d64a6bde457b0c1c74b71ee6ca6ec7555974fe3..ada8b0c374f4ca58b5b917f97afa00ca0d06bea7 100644 (file)
@@ -89,6 +89,7 @@ option(ENABLE_THREADING               "Enable partial threading support."
 option(OVERRIDE_GET_RANDOM_SEED       "Override json_c_get_random_seed() with custom code."   OFF)
 option(DISABLE_EXTRA_LIBS             "Avoid linking against extra libraries, such as libbsd." OFF)
 option(DISABLE_JSON_POINTER           "Disable JSON pointer (RFC6901) support."               OFF)
+option(NEWLOCALE_NEEDS_FREELOCALE     "Work around newlocale bugs in old FreeBSD by calling freelocale"  OFF)
 
 
 if (UNIX OR MINGW OR CYGWIN)
index be0202aba95440dc489567f340b227f94e0c869b..1e6359d0c6e433a0628956d2ef7aa876a9413d2c 100644 (file)
 /* Define to 1 if you have the `uselocale' function. */
 #cmakedefine HAVE_USELOCALE
 
+/* Define to 1 if newlocale() needs freelocale() called on it's `base` argument */
+#cmakedefine NEWLOCALE_NEEDS_FREELOCALE
+
 /* Define to 1 if you have the `vasprintf' function. */
 #cmakedefine HAVE_VASPRINTF
 
index 25f41dcbaf0394cca5405d3f833cebea69823c05..9403f8501c7788f5d0498d3ddea9656d9ba72a77 100644 (file)
@@ -344,6 +344,11 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *
                        freelocale(duploc);
                        return NULL;
                }
+#ifdef NEWLOCALE_NEEDS_FREELOCALE
+               // Older versions of FreeBSD (<12.4) don't free the locale
+               // passed to newlocale(), so do it here
+               freelocale(duploc);
+#endif
                uselocale(newloc);
        }
 #elif defined(HAVE_SETLOCALE)