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

Side by Side Diff: Source/modules/websockets/WebSocket.cpp

Issue 242323003: Crash the renderer when WebSocket fails to allocate an ArrayBuffer to set to a MessageEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 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 | Source/modules/websockets/WorkerThreadableWebSocketChannel.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/inspector/ScriptCallStack.h" 47 #include "core/inspector/ScriptCallStack.h"
48 #include "modules/websockets/CloseEvent.h" 48 #include "modules/websockets/CloseEvent.h"
49 #include "platform/Logging.h" 49 #include "platform/Logging.h"
50 #include "platform/blob/BlobData.h" 50 #include "platform/blob/BlobData.h"
51 #include "platform/heap/Handle.h" 51 #include "platform/heap/Handle.h"
52 #include "platform/weborigin/KnownPorts.h" 52 #include "platform/weborigin/KnownPorts.h"
53 #include "platform/weborigin/SecurityOrigin.h" 53 #include "platform/weborigin/SecurityOrigin.h"
54 #include "public/platform/Platform.h" 54 #include "public/platform/Platform.h"
55 #include "wtf/ArrayBuffer.h" 55 #include "wtf/ArrayBuffer.h"
56 #include "wtf/ArrayBufferView.h" 56 #include "wtf/ArrayBufferView.h"
57 #include "wtf/Assertions.h"
57 #include "wtf/HashSet.h" 58 #include "wtf/HashSet.h"
58 #include "wtf/PassOwnPtr.h" 59 #include "wtf/PassOwnPtr.h"
59 #include "wtf/StdLibExtras.h" 60 #include "wtf/StdLibExtras.h"
60 #include "wtf/text/CString.h" 61 #include "wtf/text/CString.h"
61 #include "wtf/text/StringBuilder.h" 62 #include "wtf/text/StringBuilder.h"
62 #include "wtf/text/WTFString.h" 63 #include "wtf/text/WTFString.h"
63 64
64 using namespace std; 65 using namespace std;
65 66
66 namespace WebCore { 67 namespace WebCore {
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 RefPtr<RawData> rawData = RawData::create(); 629 RefPtr<RawData> rawData = RawData::create();
629 binaryData->swap(*rawData->mutableData()); 630 binaryData->swap(*rawData->mutableData());
630 OwnPtr<BlobData> blobData = BlobData::create(); 631 OwnPtr<BlobData> blobData = BlobData::create();
631 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); 632 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile);
632 RefPtrWillBeRawPtr<Blob> blob = Blob::create(BlobDataHandle::create(blob Data.release(), size)); 633 RefPtrWillBeRawPtr<Blob> blob = Blob::create(BlobDataHandle::create(blob Data.release(), size));
633 m_eventQueue->dispatch(MessageEvent::create(blob.release(), SecurityOrig in::create(m_url)->toString())); 634 m_eventQueue->dispatch(MessageEvent::create(blob.release(), SecurityOrig in::create(m_url)->toString()));
634 break; 635 break;
635 } 636 }
636 637
637 case BinaryTypeArrayBuffer: 638 case BinaryTypeArrayBuffer:
638 m_eventQueue->dispatch(MessageEvent::create(ArrayBuffer::create(binaryDa ta->data(), binaryData->size()), SecurityOrigin::create(m_url)->toString())); 639 RefPtr<ArrayBuffer> arrayBuffer = ArrayBuffer::create(binaryData->data() , binaryData->size());
640 if (!arrayBuffer) {
641 // Failed to allocate an ArrayBuffer. We need to crash the renderer
642 // since there's no way defined in the spec to tell this to the
643 // user.
644 CRASH();
645 }
646 m_eventQueue->dispatch(MessageEvent::create(arrayBuffer.release(), Secur ityOrigin::create(m_url)->toString()));
639 break; 647 break;
640 } 648 }
641 } 649 }
642 650
643 void WebSocket::didReceiveMessageError() 651 void WebSocket::didReceiveMessageError()
644 { 652 {
645 WTF_LOG(Network, "WebSocket %p didReceiveMessageError()", this); 653 WTF_LOG(Network, "WebSocket %p didReceiveMessageError()", this);
646 m_state = CLOSED; 654 m_state = CLOSED;
647 m_eventQueue->dispatch(Event::create(EventTypeNames::error)); 655 m_eventQueue->dispatch(Event::create(EventTypeNames::error));
648 } 656 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 return overhead; 696 return overhead;
689 } 697 }
690 698
691 void WebSocket::trace(Visitor* visitor) 699 void WebSocket::trace(Visitor* visitor)
692 { 700 {
693 visitor->trace(m_channel); 701 visitor->trace(m_channel);
694 visitor->trace(m_eventQueue); 702 visitor->trace(m_eventQueue);
695 } 703 }
696 704
697 } // namespace WebCore 705 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/modules/websockets/WorkerThreadableWebSocketChannel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698