Ignore:
Timestamp:
May 12, 2009, 1:27:28 PM (16 years ago)
Author:
[email protected]
Message:

Unsigned underflow on 64bit cannot be treated as a negative number

Reviewed by Geoff Garen

This code included some placeswhere we deliberately create negative offsets
from unsigned values, on 32bit this is "safe", but in 64bit builds much
badness occurs. Solution is to use signed types as nature intended.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r43560 r43583  
    15861586    uint32_t argCount = 0;
    15871587    if (!arguments) {
    1588         argCount = (uint32_t)(callFrame[RegisterFile::ArgumentCount].u.i) - 1;
     1588        int providedParams = callFrame[RegisterFile::ArgumentCount].u.i - 1;
     1589        argCount = providedParams;
    15891590        int32_t sizeDelta = argsOffset + argCount + RegisterFile::CallFrameHeaderSize;
    15901591        Register* newEnd = callFrame->registers() + sizeDelta;
     
    15931594            VM_THROW_EXCEPTION();
    15941595        }
    1595         uint32_t expectedParams = asFunction(callFrame[RegisterFile::Callee].jsValue())->body()->parameterCount();
    1596         uint32_t inplaceArgs = min(argCount, expectedParams);
    1597         uint32_t i = 0;
     1596        int32_t expectedParams = asFunction(callFrame[RegisterFile::Callee].jsValue())->body()->parameterCount();
     1597        int32_t inplaceArgs = min(providedParams, expectedParams);
     1598        int32_t i = 0;
    15981599        Register* argStore = callFrame->registers() + argsOffset;
    15991600       
     
    16021603            argStore[i] = callFrame->registers()[i - RegisterFile::CallFrameHeaderSize - expectedParams];
    16031604        // Then we copy any additional arguments that may be further up the stack ('-1' to account for 'this')
    1604         for (; i < argCount; i++)
    1605             argStore[i] = callFrame->registers()[i - RegisterFile::CallFrameHeaderSize - expectedParams - argCount - 1];
     1605        for (; i < providedParams; i++)
     1606            argStore[i] = callFrame->registers()[i - RegisterFile::CallFrameHeaderSize - expectedParams - providedParams - 1];
    16061607    } else if (!arguments.isUndefinedOrNull()) {
    16071608        if (!arguments.isObject()) {
Note: See TracChangeset for help on using the changeset viewer.