Review Request: KJS: Correctly get begin, deleteCount for Splice

1 view
Skip to first unread message

Bernd Buschinski

unread,
Feb 28, 2012, 10:12:57 AM2/28/12
to kdelibs, Bernd Buschinski
This is an automatically generated e-mail. To reply, visit: http://git.reviewboard.kde.org/r/104104/

Review request for kdelibs.
By Bernd Buschinski.

Description

Corretly get the begin and deleteCount for Splice. The current implementation only allows max int values.
But ecmascript 15.4.4.12 allows max UInt32 (via ToInteger(which is a double) and limits it to the array length(uint32))

Testing

Confirmed via ecmascript 15.4.4.12
Bugs: 276629

Diffs

  • kjs/array_object.cpp (0da29b0)

View Diff

Maks Orlovich

unread,
Mar 20, 2012, 5:42:13 PM3/20/12
to Maks Orlovich, kdelibs, Bernd Buschinski
This is an automatically generated e-mail. To reply, visit: http://git.reviewboard.kde.org/r/104104/

kjs/array_object.cpp (Diff revision 1)
JSValue* ArrayProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
393
    if ( begin < 0 )
393
    unsigned int begin = 0;
Consider using uint32_t?

kjs/array_object.cpp (Diff revision 1)
JSValue* ArrayProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
395
      begin = (unsigned int)std::max<double>(start + length, 0);
Don't ever use C-style casts in C++; use static_cast here instead

kjs/array_object.cpp (Diff revision 1)
JSValue* ArrayProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
397
    unsigned int deleteCount = minInt( maxInt( args[1]->toUInt32(exec), 0 ), length - begin );
398
    unsigned int deleteCount = (unsigned int)std::min<double>(std::max<double>(args[1]->toUInt32(exec), 0 ), length - begin);
args[1]->toInteger() here, per 15.4.4.12 step 7

- Maks


On February 28th, 2012, 3:12 p.m., Bernd Buschinski wrote:

Review request for kdelibs.
By Bernd Buschinski.

Updated Feb. 28, 2012, 3:12 p.m.

Bernd Buschinski

unread,
Mar 21, 2012, 7:55:17 PM3/21/12
to Maks Orlovich, kdelibs, Bernd Buschinski
This is an automatically generated e-mail. To reply, visit: http://git.reviewboard.kde.org/r/104104/

Review request for kdelibs.
By Bernd Buschinski.

Updated March 21, 2012, 11:55 p.m.

Changes

- replaced unsigned int with uint32_t
- replaced C-sytle cast with static_cast
- Fixed Step 5.4.4.12 step 7, now uses toInteger() according to the specs

Description

Corretly get the begin and deleteCount for Splice. The current implementation only allows max int values.
But ecmascript 15.4.4.12 allows max UInt32 (via ToInteger(which is a double) and limits it to the array length(uint32))

Testing

Confirmed via ecmascript 15.4.4.12
Bugs: 276629

Diffs (updated)

  • kjs/array_object.cpp (0da29b0)

View Diff

Reply all
Reply to author
Forward
0 new messages