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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 1056223002: Fix crash when posting a message to a send port with port id 0. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 1604
1605 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) { 1605 static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
1606 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size); 1606 void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
1607 return reinterpret_cast<uint8_t*>(new_ptr); 1607 return reinterpret_cast<uint8_t*>(new_ptr);
1608 } 1608 }
1609 1609
1610 1610
1611 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) { 1611 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle handle) {
1612 Isolate* isolate = Isolate::Current(); 1612 Isolate* isolate = Isolate::Current();
1613 DARTSCOPE(isolate); 1613 DARTSCOPE(isolate);
1614 if (port_id == ILLEGAL_PORT) {
1615 return false;
1616 }
1614 const Object& object = Object::Handle(isolate, Api::UnwrapHandle(handle)); 1617 const Object& object = Object::Handle(isolate, Api::UnwrapHandle(handle));
1615 uint8_t* data = NULL; 1618 uint8_t* data = NULL;
1616 MessageWriter writer(&data, &allocator, false); 1619 MessageWriter writer(&data, &allocator, false);
1617 writer.WriteMessage(object); 1620 writer.WriteMessage(object);
1618 intptr_t len = writer.BytesWritten(); 1621 intptr_t len = writer.BytesWritten();
1619 return PortMap::PostMessage(new Message( 1622 return PortMap::PostMessage(new Message(
1620 port_id, data, len, Message::kNormalPriority)); 1623 port_id, data, len, Message::kNormalPriority));
1621 } 1624 }
1622 1625
1623 1626
1624 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) { 1627 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) {
1625 Isolate* isolate = Isolate::Current(); 1628 Isolate* isolate = Isolate::Current();
1626 DARTSCOPE(isolate); 1629 DARTSCOPE(isolate);
1627 CHECK_CALLBACK_STATE(isolate); 1630 CHECK_CALLBACK_STATE(isolate);
1631 if (port_id == ILLEGAL_PORT) {
1632 return Api::NewError("%s: illegal port_id %" Pd64 ".",
1633 CURRENT_FUNC,
1634 port_id);
1635 }
1628 return Api::NewHandle(isolate, SendPort::New(port_id)); 1636 return Api::NewHandle(isolate, SendPort::New(port_id));
1629 } 1637 }
1630 1638
1631 1639
1632 DART_EXPORT Dart_Handle Dart_SendPortGetId(Dart_Handle port, 1640 DART_EXPORT Dart_Handle Dart_SendPortGetId(Dart_Handle port,
1633 Dart_Port* port_id) { 1641 Dart_Port* port_id) {
1634 Isolate* isolate = Isolate::Current(); 1642 Isolate* isolate = Isolate::Current();
1635 DARTSCOPE(isolate); 1643 DARTSCOPE(isolate);
1636 CHECK_CALLBACK_STATE(isolate); 1644 CHECK_CALLBACK_STATE(isolate);
1637 const SendPort& send_port = Api::UnwrapSendPortHandle(isolate, port); 1645 const SendPort& send_port = Api::UnwrapSendPortHandle(isolate, port);
(...skipping 3899 matching lines...) Expand 10 before | Expand all | Expand 10 after
5537 5545
5538 5546
5539 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( 5547 DART_EXPORT void Dart_RegisterRootServiceRequestCallback(
5540 const char* name, 5548 const char* name,
5541 Dart_ServiceRequestCallback callback, 5549 Dart_ServiceRequestCallback callback,
5542 void* user_data) { 5550 void* user_data) {
5543 Service::RegisterRootEmbedderCallback(name, callback, user_data); 5551 Service::RegisterRootEmbedderCallback(name, callback, user_data);
5544 } 5552 }
5545 5553
5546 } // namespace dart 5554 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698