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

Side by Side Diff: third_party/WebKit/Source/modules/peerconnection/RTCDataChannel.cpp

Issue 2888043003: Prevent access to null handler in RTCDataChannel. (Closed)
Patch Set: Add unit tests Created 3 years, 7 months 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/peerconnection/RTCDataChannelTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google 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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "modules/peerconnection/RTCDataChannel.h" 25 #include "modules/peerconnection/RTCDataChannel.h"
26 26
27 #include <memory> 27 #include <memory>
28 #include <utility>
28 #include "bindings/core/v8/ExceptionState.h" 29 #include "bindings/core/v8/ExceptionState.h"
29 #include "core/dom/DOMArrayBuffer.h" 30 #include "core/dom/DOMArrayBuffer.h"
30 #include "core/dom/DOMArrayBufferView.h" 31 #include "core/dom/DOMArrayBufferView.h"
31 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
32 #include "core/dom/ExecutionContext.h" 33 #include "core/dom/ExecutionContext.h"
33 #include "core/dom/TaskRunnerHelper.h" 34 #include "core/dom/TaskRunnerHelper.h"
34 #include "core/events/MessageEvent.h" 35 #include "core/events/MessageEvent.h"
35 #include "core/fileapi/Blob.h" 36 #include "core/fileapi/Blob.h"
36 #include "modules/peerconnection/RTCPeerConnection.h" 37 #include "modules/peerconnection/RTCPeerConnection.h"
37 #include "platform/wtf/PtrUtil.h" 38 #include "platform/wtf/PtrUtil.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 ThrowCouldNotSendDataException(exception_state); 238 ThrowCouldNotSendDataException(exception_state);
238 } 239 }
239 } 240 }
240 241
241 void RTCDataChannel::send(Blob* data, ExceptionState& exception_state) { 242 void RTCDataChannel::send(Blob* data, ExceptionState& exception_state) {
242 // FIXME: implement 243 // FIXME: implement
243 ThrowNoBlobSupportException(exception_state); 244 ThrowNoBlobSupportException(exception_state);
244 } 245 }
245 246
246 void RTCDataChannel::close() { 247 void RTCDataChannel::close() {
247 handler_->Close(); 248 if (handler_)
249 handler_->Close();
248 } 250 }
249 251
250 void RTCDataChannel::DidChangeReadyState( 252 void RTCDataChannel::DidChangeReadyState(
251 WebRTCDataChannelHandlerClient::ReadyState new_state) { 253 WebRTCDataChannelHandlerClient::ReadyState new_state) {
252 if (ready_state_ == kReadyStateClosed) 254 if (ready_state_ == kReadyStateClosed)
253 return; 255 return;
254 256
255 ready_state_ = new_state; 257 ready_state_ = new_state;
256 258
257 switch (ready_state_) { 259 switch (ready_state_) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 scheduled_event_timer_.StartOneShot(0, BLINK_FROM_HERE); 314 scheduled_event_timer_.StartOneShot(0, BLINK_FROM_HERE);
313 } 315 }
314 316
315 void RTCDataChannel::ContextDestroyed(ExecutionContext*) { 317 void RTCDataChannel::ContextDestroyed(ExecutionContext*) {
316 if (stopped_) 318 if (stopped_)
317 return; 319 return;
318 320
319 stopped_ = true; 321 stopped_ = true;
320 handler_->SetClient(nullptr); 322 handler_->SetClient(nullptr);
321 handler_.reset(); 323 handler_.reset();
324 ready_state_ = kReadyStateClosed;
322 } 325 }
323 326
324 // ActiveScriptWrappable 327 // ActiveScriptWrappable
325 bool RTCDataChannel::HasPendingActivity() const { 328 bool RTCDataChannel::HasPendingActivity() const {
326 if (stopped_) 329 if (stopped_)
327 return false; 330 return false;
328 331
329 // A RTCDataChannel object must not be garbage collected if its 332 // A RTCDataChannel object must not be garbage collected if its
330 // * readyState is connecting and at least one event listener is registered 333 // * readyState is connecting and at least one event listener is registered
331 // for open events, message events, error events, or close events. 334 // for open events, message events, error events, or close events.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 events.clear(); 378 events.clear();
376 } 379 }
377 380
378 DEFINE_TRACE(RTCDataChannel) { 381 DEFINE_TRACE(RTCDataChannel) {
379 visitor->Trace(scheduled_events_); 382 visitor->Trace(scheduled_events_);
380 EventTargetWithInlineData::Trace(visitor); 383 EventTargetWithInlineData::Trace(visitor);
381 SuspendableObject::Trace(visitor); 384 SuspendableObject::Trace(visitor);
382 } 385 }
383 386
384 } // namespace blink 387 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/peerconnection/RTCDataChannelTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698