Ignore:
Timestamp:
Mar 16, 2017, 2:53:33 PM (8 years ago)
Author:
[email protected]
Message:

The new array with spread operation needs to check for length overflows.
https://bugs.webkit.org/show_bug.cgi?id=169780
<rdar://problem/31072182>

Reviewed by Filip Pizlo.

  • dfg/DFGOperations.cpp:
  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileNewArrayWithSpread):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileNewArrayWithSpread):

  • ftl/FTLOperations.cpp:

(JSC::FTL::operationMaterializeObjectInOSR):

  • llint/LLIntSlowPaths.cpp:
  • runtime/CommonSlowPaths.cpp:

(JSC::SLOW_PATH_DECL):

  • runtime/JSGlobalObject.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ftl/FTLOperations.cpp

    r214040 r214071  
    11/*
    2  * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    439439        Structure* structure = globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous);
    440440
    441         unsigned arraySize = 0;
     441        Checked<unsigned, RecordOverflow> checkedArraySize = 0;
    442442        unsigned numProperties = 0;
    443443        for (unsigned i = materialization->properties().size(); i--;) {
     
    447447                JSValue value = JSValue::decode(values[i]);
    448448                if (JSFixedArray* fixedArray = jsDynamicCast<JSFixedArray*>(vm, value))
    449                     arraySize += fixedArray->size();
     449                    checkedArraySize += fixedArray->size();
    450450                else
    451                     arraySize += 1;
    452             }
    453         }
    454 
     451                    checkedArraySize += 1;
     452            }
     453        }
     454
     455        unsigned arraySize = checkedArraySize.unsafeGet(); // Crashes if overflowed.
    455456        JSArray* result = JSArray::tryCreateForInitializationPrivate(vm, structure, arraySize);
    456457        RELEASE_ASSERT(result);
Note: See TracChangeset for help on using the changeset viewer.