From 213a9dde780d4b31cdcf7dd14f5015633a89cec5 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 22 Mar 2011 21:20:04 -0700 Subject: [PATCH] i18n: Only close valid iconv converters in i18n_done(). iconv_open() returns (iconv_t) -1 to indicate an error. We shouldn't pass this to iconv_Close(). Reported-by: Jeremy Lavergne . John Darrington suggested that this was probably the problem, and Jeremy confirmed it with valgrind. --- src/libpspp/i18n.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index 0e461db1..fbff1772 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -609,7 +609,8 @@ i18n_done (void) { free (cvtr->tocode); free (cvtr->fromcode); - iconv_close (cvtr->conv); + if (cvtr->conv != (iconv_t) -1) + iconv_close (cvtr->conv); free (cvtr); } -- 2.30.2