From d441d6f39bb846989d95bcf5caf387b42414718d Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 13 Sep 2013 12:51:20 +0200 Subject: Import Qt5x2 branch of QtWebkit for Qt 5.2 Importing a new snapshot of webkit. Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c Reviewed-by: Allan Sandfeld Jensen --- Source/JavaScriptCore/runtime/JSStringJoiner.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'Source/JavaScriptCore/runtime/JSStringJoiner.cpp') diff --git a/Source/JavaScriptCore/runtime/JSStringJoiner.cpp b/Source/JavaScriptCore/runtime/JSStringJoiner.cpp index cbf9ba48b..7e20d2195 100644 --- a/Source/JavaScriptCore/runtime/JSStringJoiner.cpp +++ b/Source/JavaScriptCore/runtime/JSStringJoiner.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Apple Inc. All rights reserved. + * Copyright (C) 2012, 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,9 +29,9 @@ #include "ExceptionHelpers.h" #include "JSScope.h" #include "JSString.h" +#include "Operations.h" #include - namespace JSC { // The destination is 16bits, at least one string is 16 bits. @@ -94,7 +94,7 @@ static inline PassRefPtr joinStrings(const Vector& strings, return outputStringImpl.release(); } -JSValue JSStringJoiner::build(ExecState* exec) +JSValue JSStringJoiner::join(ExecState* exec) { if (!m_isValid) return throwOutOfMemoryError(exec); @@ -102,25 +102,29 @@ JSValue JSStringJoiner::build(ExecState* exec) if (!m_strings.size()) return jsEmptyString(exec); - size_t separatorLength = m_separator.length(); + Checked separatorLength = m_separator.length(); // FIXME: add special cases of joinStrings() for (separatorLength == 0) and (separatorLength == 1). ASSERT(m_strings.size() > 0); - size_t totalSeparactorsLength = separatorLength * (m_strings.size() - 1); - size_t outputStringSize = totalSeparactorsLength + m_cumulatedStringsLength; + Checked totalSeparactorsLength = separatorLength * (m_strings.size() - 1); + Checked outputStringSize = totalSeparactorsLength + m_accumulatedStringsLength; + size_t finalSize; + if (outputStringSize.safeGet(finalSize) == CheckedState::DidOverflow) + return throwOutOfMemoryError(exec); + if (!outputStringSize) return jsEmptyString(exec); RefPtr outputStringImpl; if (m_is8Bits) - outputStringImpl = joinStrings(m_strings, m_separator, outputStringSize); + outputStringImpl = joinStrings(m_strings, m_separator, finalSize); else - outputStringImpl = joinStrings(m_strings, m_separator, outputStringSize); + outputStringImpl = joinStrings(m_strings, m_separator, finalSize); if (!outputStringImpl) return throwOutOfMemoryError(exec); - return JSString::create(exec->globalData(), outputStringImpl.release()); + return JSString::create(exec->vm(), outputStringImpl.release()); } } -- cgit v1.2.1