Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(824)

Unified Diff: third_party/WebKit/Source/modules/webmidi/MIDIOutput.cpp

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webmidi/MIDIOutput.cpp
diff --git a/third_party/WebKit/Source/modules/webmidi/MIDIOutput.cpp b/third_party/WebKit/Source/modules/webmidi/MIDIOutput.cpp
index 9ea9e0dfdf9266329deb5761592abde71230d524..0e3e5b1079c1e0057cec5eb00bf665c8c22d4c5a 100644
--- a/third_party/WebKit/Source/modules/webmidi/MIDIOutput.cpp
+++ b/third_party/WebKit/Source/modules/webmidi/MIDIOutput.cpp
@@ -215,7 +215,15 @@ void MIDIOutput::send(Vector<unsigned> unsignedData, double timestamp, Exception
if (timestamp == 0.0)
timestamp = now(executionContext());
- RefPtr<DOMUint8Array> array = DOMUint8Array::create(unsignedData.size());
+ // TODO(junov): crbug.com/536816
+ // Use createOrNull instead of deprecatedCreateOrCrash. Requires determining
+ // the appropriate course of action for dealing with allocation failures, which
+ // is currently not specified in the spec. Throwing a RangeError may be
+ // appropriate considering the ECMAScript spec:
+ // http://ecma-international.org/ecma-262/6.0/#sec-createbytedatablock
+ // However the spec for MIDIOutput.send does not state that such exceptions
+ // should be re-thrown, so for now we just crash the process when out of memory.
+ RefPtr<DOMUint8Array> array = DOMUint8Array::deprecatedCreateOrCrash(unsignedData.size());
DOMUint8Array::ValueType* const arrayData = array->data();
const uint32_t arrayLength = array->length();
« no previous file with comments | « third_party/WebKit/Source/modules/webmidi/MIDIInput.cpp ('k') | third_party/WebKit/Source/modules/websockets/DOMWebSocket.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698