Diff
Modified: trunk/JSTests/ChangeLog (251391 => 251392)
--- trunk/JSTests/ChangeLog 2019-10-21 22:33:47 UTC (rev 251391)
+++ trunk/JSTests/ChangeLog 2019-10-21 22:47:16 UTC (rev 251392)
@@ -1,5 +1,15 @@
2019-10-21 Robin Morisset <[email protected]>
+ Throw the right exception upon memory exhaustion in Array::slice
+ https://bugs.webkit.org/show_bug.cgi?id=202650
+
+ Reviewed by Saam Barati.
+
+ * stress/array-slice-memory-exhaustion.js: Added.
+ (foo):
+
+2019-10-21 Robin Morisset <[email protected]>
+
Post increment/decrement should only call ToNumber once
https://bugs.webkit.org/show_bug.cgi?id=202711
Modified: trunk/Source/_javascript_Core/ChangeLog (251391 => 251392)
--- trunk/Source/_javascript_Core/ChangeLog 2019-10-21 22:33:47 UTC (rev 251391)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-10-21 22:47:16 UTC (rev 251392)
@@ -1,3 +1,20 @@
+2019-10-21 Robin Morisset <[email protected]>
+
+ Throw the right exception upon memory exhaustion in Array::slice
+ https://bugs.webkit.org/show_bug.cgi?id=202650
+
+ Reviewed by Saam Barati.
+
+ Trivial change: just use tryCreate instead of create, and throw an exception if it fails.
+ No security implication: we were just crashing instead of throwing a catchable exception.
+
+ * runtime/ArrayBuffer.cpp:
+ (JSC::ArrayBuffer::slice const):
+ (JSC::ArrayBuffer::sliceImpl const):
+ * runtime/ArrayBuffer.h:
+ * runtime/JSArrayBufferPrototype.cpp:
+ (JSC::arrayBufferProtoFuncSlice):
+
2019-10-21 Basuke Suzuki <[email protected]>
[WinCairo][PlayStation] Add automation support for RemoteInspector SocketServer implementation.
Modified: trunk/Source/_javascript_Core/runtime/ArrayBuffer.cpp (251391 => 251392)
--- trunk/Source/_javascript_Core/runtime/ArrayBuffer.cpp 2019-10-21 22:33:47 UTC (rev 251391)
+++ trunk/Source/_javascript_Core/runtime/ArrayBuffer.cpp 2019-10-21 22:47:16 UTC (rev 251392)
@@ -295,21 +295,22 @@
return clampValue(index, 0, currentLength);
}
-Ref<ArrayBuffer> ArrayBuffer::slice(double begin, double end) const
+RefPtr<ArrayBuffer> ArrayBuffer::slice(double begin, double end) const
{
return sliceImpl(clampIndex(begin), clampIndex(end));
}
-Ref<ArrayBuffer> ArrayBuffer::slice(double begin) const
+RefPtr<ArrayBuffer> ArrayBuffer::slice(double begin) const
{
return sliceImpl(clampIndex(begin), byteLength());
}
-Ref<ArrayBuffer> ArrayBuffer::sliceImpl(unsigned begin, unsigned end) const
+RefPtr<ArrayBuffer> ArrayBuffer::sliceImpl(unsigned begin, unsigned end) const
{
unsigned size = begin <= end ? end - begin : 0;
- auto result = ArrayBuffer::create(static_cast<const char*>(data()) + begin, size);
- result->setSharingMode(sharingMode());
+ auto result = ArrayBuffer::tryCreate(static_cast<const char*>(data()) + begin, size);
+ if (result)
+ result->setSharingMode(sharingMode());
return result;
}
Modified: trunk/Source/_javascript_Core/runtime/ArrayBuffer.h (251391 => 251392)
--- trunk/Source/_javascript_Core/runtime/ArrayBuffer.h 2019-10-21 22:33:47 UTC (rev 251391)
+++ trunk/Source/_javascript_Core/runtime/ArrayBuffer.h 2019-10-21 22:47:16 UTC (rev 251392)
@@ -132,8 +132,8 @@
inline size_t gcSizeEstimateInBytes() const;
- JS_EXPORT_PRIVATE Ref<ArrayBuffer> slice(double begin, double end) const;
- JS_EXPORT_PRIVATE Ref<ArrayBuffer> slice(double begin) const;
+ JS_EXPORT_PRIVATE RefPtr<ArrayBuffer> slice(double begin, double end) const;
+ JS_EXPORT_PRIVATE RefPtr<ArrayBuffer> slice(double begin) const;
inline void pin();
inline void unpin();
@@ -158,7 +158,7 @@
static Ref<ArrayBuffer> createInternal(ArrayBufferContents&&, const void*, unsigned);
static RefPtr<ArrayBuffer> tryCreate(unsigned numElements, unsigned elementByteSize, ArrayBufferContents::InitializationPolicy);
ArrayBuffer(ArrayBufferContents&&);
- Ref<ArrayBuffer> sliceImpl(unsigned begin, unsigned end) const;
+ RefPtr<ArrayBuffer> sliceImpl(unsigned begin, unsigned end) const;
inline unsigned clampIndex(double index) const;
static inline unsigned clampValue(double x, unsigned left, unsigned right);
Modified: trunk/Source/_javascript_Core/runtime/JSArrayBufferPrototype.cpp (251391 => 251392)
--- trunk/Source/_javascript_Core/runtime/JSArrayBufferPrototype.cpp 2019-10-21 22:33:47 UTC (rev 251391)
+++ trunk/Source/_javascript_Core/runtime/JSArrayBufferPrototype.cpp 2019-10-21 22:47:16 UTC (rev 251392)
@@ -55,6 +55,8 @@
end = thisObject->impl()->byteLength();
auto newBuffer = thisObject->impl()->slice(begin, end);
+ if (!newBuffer)
+ return JSValue::encode(throwOutOfMemoryError(callFrame, scope));
Structure* structure = globalObject->arrayBufferStructure(newBuffer->sharingMode());
Modified: trunk/Source/WebCore/platform/mock/mediasource/MockBox.cpp (251391 => 251392)
--- trunk/Source/WebCore/platform/mock/mediasource/MockBox.cpp 2019-10-21 22:33:47 UTC (rev 251391)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockBox.cpp 2019-10-21 22:47:16 UTC (rev 251392)
@@ -98,10 +98,10 @@
while (offset < m_length) {
auto subBuffer = data->slice(offset);
- if (MockBox::peekType(subBuffer.ptr()) != MockTrackBox::type())
+ if (MockBox::peekType(subBuffer.get()) != MockTrackBox::type())
break;
- MockTrackBox trackBox(subBuffer.ptr());
+ MockTrackBox trackBox(subBuffer.get());
offset += trackBox.length();
m_tracks.append(trackBox);
}