diff -aur a/gfx/src/gtk/nsFontMetricsPango.cpp b/gfx/src/gtk/nsFontMetricsPango.cpp --- a/gfx/src/gtk/nsFontMetricsPango.cpp 2006-02-23 13:01:42.000000000 -0800 +++ b/gfx/src/gtk/nsFontMetricsPango.cpp 2006-05-20 20:27:50.000000000 -0700 @@ -535,8 +535,13 @@ PangoLayout *layout = pango_layout_new(mPangoContext); - gchar *text = g_utf16_to_utf8(aString, aLength, + // Just copy the aString to ensure the alignment, + // it is not used anywhere else. + PRUnichar* dummy = new PRUnichar[aLength]; + memcpy(dummy, aString, aLength*sizeof(PRUnichar)); + gchar *text = g_utf16_to_utf8(dummy, aLength, NULL, NULL, NULL); + delete [] dummy; if (!text) { #ifdef DEBUG diff -aur a/intl/lwbrk/src/nsJISx4501LineBreaker.cpp b/intl/lwbrk/src/nsJISx4501LineBreaker.cpp --- a/intl/lwbrk/src/nsJISx4501LineBreaker.cpp 2004-04-18 07:21:07.000000000 -0700 +++ b/intl/lwbrk/src/nsJISx4501LineBreaker.cpp 2006-05-20 20:27:51.000000000 -0700 @@ -487,13 +487,13 @@ PRUint32 cur; for (cur = aPos; cur < aLen; ++cur) { - if (IS_SPACE(aText[cur])) + if (IS_SPACE(GetUnichar(&aText[cur]))) { *oNext = cur; *oNeedMoreText = PR_FALSE; return NS_OK; } - if (IS_CJK_CHAR(aText[cur])) + if (IS_CJK_CHAR(GetUnichar(&aText[cur]))) goto ROUTE_CJK_NEXT; } *oNext = aLen; @@ -503,13 +503,13 @@ ROUTE_CJK_NEXT: PRInt8 c1, c2; cur = aPos; - if(NEED_CONTEXTUAL_ANALYSIS(aText[cur])) + if(NEED_CONTEXTUAL_ANALYSIS(GetUnichar(&aText[cur]))) { - c1 = this->ContextualAnalysis((cur>0)?aText[cur-1]:0, - aText[cur], - (cur<(aLen-1)) ?aText[cur+1]:0); + c1 = this->ContextualAnalysis((cur>0)?GetUnichar(&aText[cur-1]):0, + GetUnichar(&aText[cur]), + (cur<(aLen-1)) ?GetUnichar(&aText[cur+1]):0); } else { - c1 = this->GetClass(aText[cur]); + c1 = this->GetClass(GetUnichar(&aText[cur])); } if(CLASS_THAI == c1) @@ -521,13 +521,13 @@ for(cur++; cur ContextualAnalysis((cur>0)?aText[cur-1]:0, - aText[cur], - (cur<(aLen-1)) ?aText[cur+1]:0); + c2= this->ContextualAnalysis((cur>0)?GetUnichar(&aText[cur-1]):0, + GetUnichar(&aText[cur]), + (cur<(aLen-1)) ?GetUnichar(&aText[cur+1]):0); } else { - c2 = this->GetClass(aText[cur]); + c2 = this->GetClass(GetUnichar(&aText[cur])); } if(GetPair(c1, c2)) { diff -aur a/intl/unicharutil/util/nsUnicharUtils.cpp b/intl/unicharutil/util/nsUnicharUtils.cpp --- a/intl/unicharutil/util/nsUnicharUtils.cpp 2005-04-21 15:30:21.000000000 -0700 +++ b/intl/unicharutil/util/nsUnicharUtils.cpp 2006-05-20 20:27:50.000000000 -0700 @@ -340,3 +340,28 @@ return result; } +PRUnichar +GetUnichar(const void *ptr) +{ + PRUnichar result; +#if defined(__sparc__) || defined(__alpha__) + *((char *) &result) = *((char *) ptr); + *((char *) &result + 1) = *((char *) ptr + 1); +#else + result = *((PRUnichar *) ptr); +#endif + return result; +} + +void +SetUnichar(void *ptr, PRUnichar aChar) +{ +#if defined(__sparc__) || defined(__alpha__) + *((char *) ptr) = *((char *) &aChar); + *((char *) ptr + 1) = *((char *) &aChar + 1); +#else + *((PRUnichar *) ptr) = aChar; +#endif +} + + diff -aur a/intl/unicharutil/util/nsUnicharUtils.h b/intl/unicharutil/util/nsUnicharUtils.h --- a/intl/unicharutil/util/nsUnicharUtils.h 2005-02-24 07:50:57.000000000 -0800 +++ b/intl/unicharutil/util/nsUnicharUtils.h 2006-05-20 20:27:50.000000000 -0700 @@ -81,6 +81,8 @@ PRUnichar ToUpperCase(PRUnichar); PRUnichar ToLowerCase(PRUnichar); +PRUnichar GetUnichar(const void *); +void SetUnichar(void *, PRUnichar); inline PRBool IsUpperCase(PRUnichar c) { return ToLowerCase(c) != c; diff -aur a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp --- a/layout/generic/nsTextFrame.cpp 2006-02-13 18:05:07.000000000 -0800 +++ b/layout/generic/nsTextFrame.cpp 2006-05-20 20:27:50.000000000 -0700 @@ -5101,8 +5101,8 @@ while (aNumChars-- > 0) { // XXX: If you crash here then you may see the issue described - // in http://bugzilla.mozilla.org/show_bug.cgi?id=36146#c44 - *cp2-- = PRUnichar(*cp1--); + // in http://bugzilla.mozilla.org/show_bug.cgi?id=161826 + SetUnichar(cp2--, PRUnichar(*cp1--)); } } @@ -6199,9 +6199,9 @@ { PRUnichar* end = aBuffer + aWordLen; for (; aBuffer < end; aBuffer++) { - PRUnichar ch = *aBuffer; + PRUnichar ch = GetUnichar(aBuffer); if (ch == ' ') { - *aBuffer = CH_NBSP; + SetUnichar(aBuffer, CH_NBSP); } } }