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

Side by Side Diff: third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 // (blink side doesn't know what the CDM supports, so the proper check 427 // (blink side doesn't know what the CDM supports, so the proper check
428 // will be done on the Chromium side. However, we can verify that 428 // will be done on the Chromium side. However, we can verify that
429 // |initDataType| is one of the registered values.) 429 // |initDataType| is one of the registered values.)
430 WebEncryptedMediaInitDataType initDataType = EncryptedMediaUtils::convertToI nitDataType(initDataTypeString); 430 WebEncryptedMediaInitDataType initDataType = EncryptedMediaUtils::convertToI nitDataType(initDataTypeString);
431 if (initDataType == WebEncryptedMediaInitDataType::Unknown) { 431 if (initDataType == WebEncryptedMediaInitDataType::Unknown) {
432 return ScriptPromise::rejectWithDOMException( 432 return ScriptPromise::rejectWithDOMException(
433 scriptState, DOMException::create(NotSupportedError, "The initializa tion data type '" + initDataTypeString + "' is not supported.")); 433 scriptState, DOMException::create(NotSupportedError, "The initializa tion data type '" + initDataTypeString + "' is not supported."));
434 } 434 }
435 435
436 // 6. Let init data be a copy of the contents of the initData parameter. 436 // 6. Let init data be a copy of the contents of the initData parameter.
437 RefPtr<DOMArrayBuffer> initDataBuffer = DOMArrayBuffer::create(initData.data (), initData.byteLength()); 437 // TODO(junov): crbug.com/536816
438 // Use createOrNull instead of deprecatedCreateOrCrash. It would probably
439 // be appropriate to reject the promise with a RangeError exception when
440 // array buffer allocation fails, but that behavior probably needs
441 // clarification in the spec.
442 RefPtr<DOMArrayBuffer> initDataBuffer = DOMArrayBuffer::deprecatedCreateOrCr ash(initData.data(), initData.byteLength());
438 443
439 // 7. Let session type be this object's session type. 444 // 7. Let session type be this object's session type.
440 // (Done in constructor.) 445 // (Done in constructor.)
441 446
442 // 8. Let promise be a new promise. 447 // 8. Let promise be a new promise.
443 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t his); 448 NewSessionResultPromise* result = new NewSessionResultPromise(scriptState, t his);
444 ScriptPromise promise = result->promise(); 449 ScriptPromise promise = result->promise();
445 450
446 // 9. Run the following steps asynchronously (documented in 451 // 9. Run the following steps asynchronously (documented in
447 // actionTimerFired()) 452 // actionTimerFired())
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 return CreateRejectedPromiseNotCallable(scriptState); 527 return CreateRejectedPromiseNotCallable(scriptState);
523 528
524 // 2. If response is an empty array, return a promise rejected with a 529 // 2. If response is an empty array, return a promise rejected with a
525 // new DOMException whose name is InvalidAccessError. 530 // new DOMException whose name is InvalidAccessError.
526 if (!response.byteLength()) { 531 if (!response.byteLength()) {
527 return ScriptPromise::rejectWithDOMException( 532 return ScriptPromise::rejectWithDOMException(
528 scriptState, DOMException::create(InvalidAccessError, "The response parameter is empty.")); 533 scriptState, DOMException::create(InvalidAccessError, "The response parameter is empty."));
529 } 534 }
530 535
531 // 3. Let response copy be a copy of the contents of the response parameter. 536 // 3. Let response copy be a copy of the contents of the response parameter.
532 RefPtr<DOMArrayBuffer> responseCopy = DOMArrayBuffer::create(response.data() , response.byteLength()); 537 // TODO(junov): crbug.com/536816
538 // Use createOrNull instead of deprecatedCreateOrCrash. It would probably
539 // be appropriate to reject the promise with a RangeError exception when
540 // array buffer allocation fails, but that behavior probably needs
541 // clarification in the spec.
542 RefPtr<DOMArrayBuffer> responseCopy = DOMArrayBuffer::deprecatedCreateOrCras h(response.data(), response.byteLength());
533 543
534 // 4. Let promise be a new promise. 544 // 4. Let promise be a new promise.
535 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp tionModuleResultPromise(scriptState); 545 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp tionModuleResultPromise(scriptState);
536 ScriptPromise promise = result->promise(); 546 ScriptPromise promise = result->promise();
537 547
538 // 5. Run the following steps asynchronously (documented in 548 // 5. Run the following steps asynchronously (documented in
539 // actionTimerFired()) 549 // actionTimerFired())
540 m_pendingActions.append(PendingAction::CreatePendingUpdate(result, responseC opy.release())); 550 m_pendingActions.append(PendingAction::CreatePendingUpdate(result, responseC opy.release()));
541 if (!m_actionTimer.isActive()) 551 if (!m_actionTimer.isActive())
542 m_actionTimer.startOneShot(0, BLINK_FROM_HERE); 552 m_actionTimer.startOneShot(0, BLINK_FROM_HERE);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRequest: 803 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRequest:
794 init.setMessageType("license-request"); 804 init.setMessageType("license-request");
795 break; 805 break;
796 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRenewal: 806 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRenewal:
797 init.setMessageType("license-renewal"); 807 init.setMessageType("license-renewal");
798 break; 808 break;
799 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRelease: 809 case WebContentDecryptionModuleSession::Client::MessageType::LicenseRelease:
800 init.setMessageType("license-release"); 810 init.setMessageType("license-release");
801 break; 811 break;
802 } 812 }
803 init.setMessage(DOMArrayBuffer::create(static_cast<const void*>(message), me ssageLength)); 813 init.setMessage(DOMArrayBuffer::deprecatedCreateOrCrash(static_cast<const vo id*>(message), messageLength));
804 814
805 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat e(EventTypeNames::message, init); 815 RefPtrWillBeRawPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::creat e(EventTypeNames::message, init);
806 event->setTarget(this); 816 event->setTarget(this);
807 m_asyncEventQueue->enqueueEvent(event.release()); 817 m_asyncEventQueue->enqueueEvent(event.release());
808 } 818 }
809 819
810 void MediaKeySession::close() 820 void MediaKeySession::close()
811 { 821 {
812 WTF_LOG(Media, "MediaKeySession(%p)::close", this); 822 WTF_LOG(Media, "MediaKeySession(%p)::close", this);
813 823
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 visitor->trace(m_asyncEventQueue); 935 visitor->trace(m_asyncEventQueue);
926 visitor->trace(m_pendingActions); 936 visitor->trace(m_pendingActions);
927 visitor->trace(m_mediaKeys); 937 visitor->trace(m_mediaKeys);
928 visitor->trace(m_keyStatusesMap); 938 visitor->trace(m_keyStatusesMap);
929 visitor->trace(m_closedPromise); 939 visitor->trace(m_closedPromise);
930 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace( visitor); 940 RefCountedGarbageCollectedEventTargetWithInlineData<MediaKeySession>::trace( visitor);
931 ActiveDOMObject::trace(visitor); 941 ActiveDOMObject::trace(visitor);
932 } 942 }
933 943
934 } // namespace blink 944 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698