Closed
Bug 512700
Opened 15 years ago
Closed 15 years ago
String::containsLatin1 comparison fails on windows for characters > 0x7F
Categories
(Tamarin Graveyard :: Virtual Machine, defect)
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: jeremyahall, Assigned: stejohns)
Details
Attachments
(1 file)
8.76 KB,
patch
|
edwsmith
:
review+
lhansen
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 Build Identifier: AVMPLUS 1.4 2007-04-01/2009-04-24 I was calling String::containsLatin1("\xAD") to find out if a string contained a soft-hyphen character, but on Windows this function fails if the underlying string is represented by an 8-bit buffer. The failure occurs on line 764 of StringObject.cpp: if (selfBuf.p8[j] != p[j]) break; because elements of "p8" are of type "unsigned char" and elements of "p" are of type "char". On Windows "char" is a signed type so this code becomes a signed/unsigned comparison. I believe in this case that the compiler will promote each side to "int" and because value preserving rules the negative number will be sign extended and will never compare equal. Simply casting "p[j]" to "uint8_t" fixes the problem. Note: there may be other instances of this kind of bug in the String class, e.g. String::indexOfLatin1 or String::matchesLatin1. Reproducible: Always Steps to Reproduce: 1. Create string with content: "ev-i-dent" where hyphen character is a soft hyphen: 0xAD 2. Call containsLatin1("\xAD") on string Actual Results: Step 2 returns false on windows. Other platforms where type char is signed will also exhibit this behavior. Expected Results: Step 2 should return true.
Assignee | ||
Updated•15 years ago
|
Assignee: nobody → stejohns
Assignee | ||
Comment 1•15 years ago
|
||
Nice catch. I'll add appropriate testcases along with the fix.
Assignee | ||
Comment 2•15 years ago
|
||
Fixes the bug. Also adds selftests for the relevant String apis (and fixes some minor issues with compiling in selftest mode under Xcode.)
Attachment #396819 -
Flags: superreview?(lhansen)
Attachment #396819 -
Flags: review?(edwsmith)
Updated•15 years ago
|
Attachment #396819 -
Flags: superreview?(lhansen) → superreview+
Updated•15 years ago
|
Attachment #396819 -
Flags: review?(edwsmith) → review+
Assignee | ||
Comment 3•15 years ago
|
||
pushed fix to redux as changeset: 2409:b0fb0a8a6bf4
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Updated•15 years ago
|
Status: RESOLVED → VERIFIED
Flags: in-testsuite+
You need to log in
before you can comment on or make changes to this bug.
Description
•