summaryrefslogtreecommitdiff
path: root/src/readcdf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/readcdf.c')
-rw-r--r--src/readcdf.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/readcdf.c b/src/readcdf.c
index e6ea8e47fb6b4..7622c7b08aaaa 100644
--- a/src/readcdf.c
+++ b/src/readcdf.c
@@ -26,7 +26,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.73 2019/03/12 20:43:05 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.74 2019/09/11 15:46:30 christos Exp $")
#endif
#include <assert.h>
@@ -120,7 +120,11 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv)
old_lc_ctype = uselocale(c_lc_ctype);
assert(old_lc_ctype != NULL);
#else
- char *old_lc_ctype = setlocale(LC_CTYPE, "C");
+ char *old_lc_ctype = setlocale(LC_CTYPE, NULL);
+ assert(old_lc_ctype != NULL);
+ old_lc_ctype = strdup(old_lc_ctype);
+ assert(old_lc_ctype != NULL);
+ (void)setlocale(LC_CTYPE, "C");
#endif
for (i = 0; nv[i].pattern != NULL; i++)
if (strcasestr(vbuf, nv[i].pattern) != NULL) {
@@ -134,7 +138,8 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv)
(void)uselocale(old_lc_ctype);
freelocale(c_lc_ctype);
#else
- setlocale(LC_CTYPE, old_lc_ctype);
+ (void)setlocale(LC_CTYPE, old_lc_ctype);
+ free(old_lc_ctype);
#endif
return rv;
}