all repos — fluxbox @ 79a358346a650a40c0e0f0409b264bf3e3cb23a4

custom fork of the fluxbox windowmanager

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.
Casey Dahlin casey.dahlin@toshibagcs.com
commit

79a358346a650a40c0e0f0409b264bf3e3cb23a4

parent

88a74ff1cde22be3e894498ffd88934dc92dfef0

1 files changed, 9 insertions(+), 5 deletions(-)

jump to
M src/FbTk/FbString.ccsrc/FbTk/FbString.cc

@@ -168,6 +168,10 @@

s_inited = true; setlocale(LC_CTYPE, ""); + for (int i = 0; i < CONVSIZE; i++) { + s_iconv_convs[i] = ICONV_NULL; + } + #ifdef HAVE_ICONV #if defined(CODESET) && !defined(_WIN32) s_locale_codeset = nl_langinfo(CODESET);

@@ -186,8 +190,6 @@ s_iconv_convs[FB2X] = iconv_open("ISO8859-1", "UTF-8");

s_iconv_convs[X2FB] = iconv_open("UTF-8", "ISO8859-1"); s_iconv_convs[FB2LOCALE] = iconv_open(s_locale_codeset.c_str(), "UTF-8"); s_iconv_convs[LOCALE2FB] = iconv_open("UTF-8", s_locale_codeset.c_str()); -#else - memset(s_iconv_convs, 0, sizeof(s_iconv_convs)); #endif // HAVE_ICONV }

@@ -195,11 +197,13 @@

void shutdown() { #ifdef HAVE_ICONV int i; - for (i = 0; i < CONVSIZE; ++i) - if (s_iconv_convs[i] != ICONV_NULL) + for (i = 0; i < CONVSIZE; ++i) { + if (s_iconv_convs[i] != ICONV_NULL) { iconv_close(s_iconv_convs[i]); + s_iconv_convs[i] = ICONV_NULL; + } + } - memset(s_iconv_convs, 0, sizeof(s_iconv_convs)); s_inited = false; #endif // HAVE_ICONV }