Closed Bug 377942 Opened 17 years ago Closed 17 years ago

UCS-2 low byte data treated as UTF-8 in gfxPangofontGroup::MakeTextRun()

Categories

(Core :: Graphics, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: karlt, Assigned: karlt)

References

Details

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.3) Gecko/20070405 Firefox/2.0.0.3
Build Identifier: Trunk

With MOZ_ENABLE_NEW_TEXT_FRAME = 1 in layout/generic/Makefile.in,
gfxPangofontGroup::MakeTextRun(const PRUint8 *aString, PRUint32 aLength,
Parameters *aParams) is called from
BuildTextRunsScanner::BuildTextRunForFrames() with aString containing char data,
for which (according to nsTextFragment documentation) "each byte of data
represents a single ucs2 character with the high byte being zero."

However, gfxPangofontGroup::MakeTextRun(const PRUint8 *aString, PRUint32
aLength, Parameters *aParams) treats the data as utf8, resulting in
misinterpretation of the data in g_utf8_get_char from
gfxPangoFontGroup::CreateGlyphRunsXft().



Reproducible: Always

Steps to Reproduce:
1. Build with MOZ_ENABLE_NEW_TEXT_FRAME = 1,
2. Load a page containing U+00F4.

Actual Results:  
SIGSEGV while in gfxTextRun::BreakAndMeasureText
(which looks like another bug, which I'll look at).


Expected Results:  
Côte

I'll attach a test case demonstrating the problem and a patch.

[With MOZ_ENABLE_NEW_TEXT_FRAME empty, this problem doesn't seem to get hit
possibly due to the use of nsTextTransformer::TransformedTextIsAscii() in
nsTextFrame::MeasureText().]
Attached file test case
Attachment #262021 - Flags: review?(roc)
+    if ( aParams->mFlags & TEXT_IS_ASCII && !isRTL ) {

Follow file style, don't put spaces after ( or before ). Also I tend to parenthesize &-expressions in && or || expressions because I'm afraid of getting C precedence wrong (and I think most of our other code does that too).

Other than that, looks good.
style changes
Attachment #262021 - Attachment is obsolete: true
Attachment #262026 - Flags: review?(roc)
Attachment #262021 - Flags: review?(roc)
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee: nobody → mozbugz
Status: ASSIGNED → NEW
checked in
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: