Closed
Bug 126159
Opened 23 years ago
Closed 23 years ago
Integer not always converted to integer correctly
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
FIXED
People
(Reporter: shd, Assigned: khanson)
Details
Attachments
(1 file)
542 bytes,
patch
|
shaver
:
review+
jband_mozilla
:
superreview+
|
Details | Diff | Splinter Review |
I use the SpiderMonkey engine in a project of my own. I have found that some
values specified as integers, although stored correctly, are incorrectly
converted by JS_ValueToInt32 (and possibly others as well).
JavaScript:
const WHITE=0xFFFFFF;
CallCFunction (WHITE);
C:
#define WHITE 0xFFFFFF
int i;
JS_ValueToInt32 (cx, *vp, &b);
if (i == WHITE)
{
printf ("OK!");
} else {
printf ("0x%08X", i);
}
Output:
0x01000000
Perhaps JS_ValueToInt32 should first check JSVAL_IS_INT. That would also
eliminate the conversion to double and other operations, thereby increasing
performance.
Reporter | ||
Comment 1•23 years ago
|
||
The &b is a typo and should be &i, obviously.
Comment 2•23 years ago
|
||
cc'ing Brendan on this one -
Assignee: rogerl → khanson
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Integer not always converted to integer correctly. → Integer not always converted to integer correctly
Comment 3•23 years ago
|
||
JS_ValueToInt32 is an old API entry point, deprecated in favor of
JS_ValueToECMAInt32. If you can use the latter, please do so.
I agree that js_ValueToInt32 in jsnum.c should have an early out for int-tagged
jsvals, patch coming up. I trust doing so will not break anyone using this old
API -- it is an incompatible change, however! Presumably, anyone using it was
not counting on the buggy behavior Steven reports.
/be
Comment 4•23 years ago
|
||
Let's try for 0.9.9, this is an easy one.
/be
Comment 5•23 years ago
|
||
Comment on attachment 70133 [details] [diff] [review]
proposed fix
r=shaver.
(If jband finds something I missed in _this_ one, I'm hanging up my spurs.)
Attachment #70133 -
Flags: review+
Comment 6•23 years ago
|
||
Comment on attachment 70133 [details] [diff] [review]
proposed fix
sr=jband
Attachment #70133 -
Flags: superreview+
You need to log in
before you can comment on or make changes to this bug.
Description
•