aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCasey Dahlin <casey.dahlin@toshibagcs.com>2015-04-09 19:01:35 (GMT)
committerMathias Gumz <akira@fluxbox.org>2015-04-11 06:25:59 (GMT)
commit79a358346a650a40c0e0f0409b264bf3e3cb23a4 (patch)
treeab18e74c247624aa4dd2be5f5783e28dd52b4fd9 /src
parent88a74ff1cde22be3e894498ffd88934dc92dfef0 (diff)
downloadfluxbox-79a358346a650a40c0e0f0409b264bf3e3cb23a4.zip
fluxbox-79a358346a650a40c0e0f0409b264bf3e3cb23a4.tar.bz2
Don't assume ICONV_NULL = 0
We define the value ICONV_NULL = -1, but when we attempt to set the s_iconv_convs array to all NULL values, we zero the array instead of setting its entries to -1. This patch properly initializes and wipes s_iconv_convs.
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/FbString.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/FbTk/FbString.cc b/src/FbTk/FbString.cc
index 2bc7516..9c7fca7 100644
--- a/src/FbTk/FbString.cc
+++ b/src/FbTk/FbString.cc
@@ -168,6 +168,10 @@ void init() {
168 s_inited = true; 168 s_inited = true;
169 setlocale(LC_CTYPE, ""); 169 setlocale(LC_CTYPE, "");
170 170
171 for (int i = 0; i < CONVSIZE; i++) {
172 s_iconv_convs[i] = ICONV_NULL;
173 }
174
171#ifdef HAVE_ICONV 175#ifdef HAVE_ICONV
172#if defined(CODESET) && !defined(_WIN32) 176#if defined(CODESET) && !defined(_WIN32)
173 s_locale_codeset = nl_langinfo(CODESET); 177 s_locale_codeset = nl_langinfo(CODESET);
@@ -186,8 +190,6 @@ void init() {
186 s_iconv_convs[X2FB] = iconv_open("UTF-8", "ISO8859-1"); 190 s_iconv_convs[X2FB] = iconv_open("UTF-8", "ISO8859-1");
187 s_iconv_convs[FB2LOCALE] = iconv_open(s_locale_codeset.c_str(), "UTF-8"); 191 s_iconv_convs[FB2LOCALE] = iconv_open(s_locale_codeset.c_str(), "UTF-8");
188 s_iconv_convs[LOCALE2FB] = iconv_open("UTF-8", s_locale_codeset.c_str()); 192 s_iconv_convs[LOCALE2FB] = iconv_open("UTF-8", s_locale_codeset.c_str());
189#else
190 memset(s_iconv_convs, 0, sizeof(s_iconv_convs));
191#endif // HAVE_ICONV 193#endif // HAVE_ICONV
192 194
193} 195}
@@ -195,11 +197,13 @@ void init() {
195void shutdown() { 197void shutdown() {
196#ifdef HAVE_ICONV 198#ifdef HAVE_ICONV
197 int i; 199 int i;
198 for (i = 0; i < CONVSIZE; ++i) 200 for (i = 0; i < CONVSIZE; ++i) {
199 if (s_iconv_convs[i] != ICONV_NULL) 201 if (s_iconv_convs[i] != ICONV_NULL) {
200 iconv_close(s_iconv_convs[i]); 202 iconv_close(s_iconv_convs[i]);
203 s_iconv_convs[i] = ICONV_NULL;
204 }
205 }
201 206
202 memset(s_iconv_convs, 0, sizeof(s_iconv_convs));
203 s_inited = false; 207 s_inited = false;
204#endif // HAVE_ICONV 208#endif // HAVE_ICONV
205} 209}