[Webkit-unassigned] [Bug 10820] Add StringImpl::toDouble() and remove uses of .deprecatedString().toDouble()
bugzilla-daemon at opendarwin.org
bugzilla-daemon at opendarwin.org
Tue Sep 26 00:25:58 PDT 2006
http://bugzilla.opendarwin.org/show_bug.cgi?id=10820
acarlsson at apple.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #10509|0 |1
is obsolete| |
AssignedTo|webkit- |acarlsson at apple.com
|unassigned at opendarwin.org |
Status|NEW |ASSIGNED
Attachment #10778| |review?
Flag| |
------- Comment #3 from acarlsson at apple.com 2006-09-26 00:25 PDT -------
Created an attachment (id=10778)
--> (http://bugzilla.opendarwin.org/attachment.cgi?id=10778&action=view)
Non-broken patch
I found two problems with the toDouble implementation:
+double StringImpl::toDouble(bool* ok) const
+{
+ if (empty()) {
this should be isEmpty(). empty() returns the special empty string singleton so
this is always true.
+ if (ok)
+ *ok = false;
+ return 0;
+ }
+ char *end;
+ double val = kjs_strtod(Latin1Encoding().encode(characters(),
length()).data(), &end);
+ if (ok)
+ *ok = end == 0 || *end == '\0';
TextEncoding::encode returns a CString which is destroyed after calling
kjs_strtod. This makes the end pointer dangling so *end could potentially
crash.
+ return val;
+}
I've uploaded a patch that doesn't break any layout tests.
--
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list