2004-08-26 [colin] 0.9.12cvs82.4
authorColin Leroy <colin@colino.net>
Thu, 26 Aug 2004 21:57:13 +0000 (21:57 +0000)
committerColin Leroy <colin@colino.net>
Thu, 26 Aug 2004 21:57:13 +0000 (21:57 +0000)
* src/codeconv.c
Fix strange stack corruption
Convert to utf8 after unmime, not before

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/codeconv.c

index 1d95316b97061dd983c3797b8114cd065c379260..42fd9eb258b0b5f2f7d36907666363086e5ffd37 100644 (file)
@@ -1,3 +1,9 @@
+2004-08-26 [colin]     0.9.12cvs82.4
+
+       * src/codeconv.c
+               Fix strange stack corruption
+               Convert to utf8 after unmime, not before
+
 2004-08-26 [colin]     0.9.12cvs82.3
 
        * src/main.c
index 3a87af8c35b878752552e9be18d47c8521056174..0cfdf59c02443063513e193b58cf7d7036e74db6 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/plugins/pgpmime/pgpmime.c; ) > 0.9.12cvs82.1.patchset
 ( cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/wizard.c; ) > 0.9.12cvs82.2.patchset
 ( cvs diff -u -r 1.115.2.16 -r 1.115.2.17 src/main.c; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/wizard.c; ) > 0.9.12cvs82.3.patchset
+( cvs diff -u -r 1.65.2.12 -r 1.65.2.13 src/codeconv.c; ) > 0.9.12cvs82.4.patchset
index afa999fe4078ef4961d85f7082ef38db81ff4fb6..14fcba49ee35dbfa30f7aa0f438174a21b15d37c 100644 (file)
@@ -13,7 +13,7 @@ INTERFACE_AGE=0
 BINARY_AGE=0
 EXTRA_VERSION=82
 EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.3
+EXTRA_GTK2_VERSION=.4
 
 if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
index fc042e9370085d54bd71ebb1786e87f0e610c29c..33325b70ef99fbd4f74879e748fb77bdb5f8ed23 100644 (file)
@@ -1385,8 +1385,11 @@ gboolean conv_is_multibyte_encoding(CharSet encoding)
 
 const gchar *conv_get_current_locale(void)
 {
-       const gchar *cur_locale;
+       static const gchar *cur_locale = NULL;
 
+       if (cur_locale != NULL)
+               return cur_locale;
+       
        cur_locale = g_getenv("LC_ALL");
        if (!cur_locale || !strlen(cur_locale)) 
                cur_locale = g_getenv("LC_CTYPE");
@@ -1395,8 +1398,11 @@ const gchar *conv_get_current_locale(void)
        if (!cur_locale || !strlen(cur_locale)) 
                cur_locale = setlocale(LC_CTYPE, NULL);
 
-/*     debug_print("current locale: %s\n",
-                   cur_locale ? cur_locale : "(none)"); */
+       if (cur_locale && strlen(cur_locale)) {
+               gchar *tmp = g_strdup(cur_locale);
+               cur_locale = g_strdup(tmp);
+               g_free(tmp);
+       }
 
        return cur_locale;
 }
@@ -1432,11 +1438,10 @@ void conv_unmime_header_overwrite(gchar *str)
 void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
                        const gchar *charset)
 {
-       CharSet cur_charset;
        const gchar *locale;
 
-       cur_charset = conv_get_current_charset();
-
+       memset(outbuf, 0, outlen);
+       
 #warning FIXME_GTK2
 /* Should we always ensure to convert? */
        locale = conv_get_current_locale();
@@ -1449,16 +1454,18 @@ void conv_unmime_header(gchar *outbuf, gint outlen, const gchar *str,
                Xalloca(buf, buflen, return);
                conv_anytodisp(buf, buflen, str);
                unmime_header(outbuf, buf);
-       } else if (g_utf8_validate(str, -1, NULL)) {
-               unmime_header(outbuf, str);
        } else {
-               gchar *buf;
-               gint buflen;
-               const gchar *src_codeset, *dest_codeset;
-               src_codeset = conv_get_current_charset_str();
-               dest_codeset = CS_UTF_8;
-               buf = conv_codeset_strdup(str, src_codeset, dest_codeset);
-               unmime_header(outbuf, buf);
+               gchar *tmp;
+               unmime_header(outbuf, str);
+               if (outbuf && !g_utf8_validate(outbuf, -1, NULL)) {
+                       tmp = conv_codeset_strdup(outbuf,
+                                       conv_get_current_charset_str(),
+                                       CS_UTF_8);
+                       if (tmp) {
+                               strncpy(outbuf, tmp, outlen-1);
+                               g_free(tmp);
+                       }
+               }
        }
 }