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

Side by Side Diff: runtime/vm/datastream.h

Issue 2629533002: Fix leak of message snapshot buffer when attempting to send an illegal object. (Closed)
Patch Set: Created 3 years, 11 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 | « runtime/vm/dart_api_message.h ('k') | runtime/vm/isolate.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #ifndef RUNTIME_VM_DATASTREAM_H_ 5 #ifndef RUNTIME_VM_DATASTREAM_H_
6 #define RUNTIME_VM_DATASTREAM_H_ 6 #define RUNTIME_VM_DATASTREAM_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/utils.h" 9 #include "platform/utils.h"
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
11 #include "vm/exceptions.h" 11 #include "vm/exceptions.h"
12 #include "vm/globals.h" 12 #include "vm/globals.h"
13 #include "vm/os.h" 13 #include "vm/os.h"
14 14
15 namespace dart { 15 namespace dart {
16 16
17 static const int8_t kDataBitsPerByte = 7; 17 static const int8_t kDataBitsPerByte = 7;
18 static const int8_t kByteMask = (1 << kDataBitsPerByte) - 1; 18 static const int8_t kByteMask = (1 << kDataBitsPerByte) - 1;
19 static const int8_t kMaxUnsignedDataPerByte = kByteMask; 19 static const int8_t kMaxUnsignedDataPerByte = kByteMask;
20 static const int8_t kMinDataPerByte = -(1 << (kDataBitsPerByte - 1)); 20 static const int8_t kMinDataPerByte = -(1 << (kDataBitsPerByte - 1));
21 static const int8_t kMaxDataPerByte = (~kMinDataPerByte & kByteMask); // NOLINT 21 static const int8_t kMaxDataPerByte = (~kMinDataPerByte & kByteMask); // NOLINT
22 static const uint8_t kEndByteMarker = (255 - kMaxDataPerByte); 22 static const uint8_t kEndByteMarker = (255 - kMaxDataPerByte);
23 static const uint8_t kEndUnsignedByteMarker = (255 - kMaxUnsignedDataPerByte); 23 static const uint8_t kEndUnsignedByteMarker = (255 - kMaxUnsignedDataPerByte);
24 24
25 typedef uint8_t* (*ReAlloc)(uint8_t* ptr, intptr_t old_size, intptr_t new_size); 25 typedef uint8_t* (*ReAlloc)(uint8_t* ptr, intptr_t old_size, intptr_t new_size);
26 typedef void (*DeAlloc)(uint8_t* ptr);
26 27
27 // Stream for reading various types from a buffer. 28 // Stream for reading various types from a buffer.
28 class ReadStream : public ValueObject { 29 class ReadStream : public ValueObject {
29 public: 30 public:
30 ReadStream(const uint8_t* buffer, intptr_t size) 31 ReadStream(const uint8_t* buffer, intptr_t size)
31 : buffer_(buffer), current_(buffer), end_(buffer + size) {} 32 : buffer_(buffer), current_(buffer), end_(buffer + size) {}
32 33
33 void SetStream(const uint8_t* buffer, intptr_t size) { 34 void SetStream(const uint8_t* buffer, intptr_t size) {
34 buffer_ = buffer; 35 buffer_ = buffer;
35 current_ = buffer; 36 current_ = buffer;
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 intptr_t current_size_; 450 intptr_t current_size_;
450 ReAlloc alloc_; 451 ReAlloc alloc_;
451 intptr_t initial_size_; 452 intptr_t initial_size_;
452 453
453 DISALLOW_COPY_AND_ASSIGN(WriteStream); 454 DISALLOW_COPY_AND_ASSIGN(WriteStream);
454 }; 455 };
455 456
456 } // namespace dart 457 } // namespace dart
457 458
458 #endif // RUNTIME_VM_DATASTREAM_H_ 459 #endif // RUNTIME_VM_DATASTREAM_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_message.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698