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

Unified Diff: runtime/vm/object.h

Issue 8231028: Ensure that the passed in raw pointer is not used in SetRaw(). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 359)
+++ runtime/vm/object.h (working copy)
@@ -6,6 +6,7 @@
#define VM_OBJECT_H_
#include "vm/assert.h"
+#include "vm/dart.h"
#include "vm/globals.h"
#include "vm/handles.h"
#include "vm/heap.h"
@@ -296,10 +297,6 @@
return reinterpret_cast<cpp_vtable*>(reinterpret_cast<word>(this));
}
-#if defined(DEBUG)
- void ValidateHeapObject(RawObject* raw_obj);
-#endif // defined(DEBUG)
-
static cpp_vtable handle_vtable_;
// The static values below are singletons shared between the different
@@ -2767,17 +2764,22 @@
void Object::SetRaw(RawObject* value) {
+ // NOTE: The assignment "raw_ = value" should be the first statement in
+ // this function, Also do not use 'value' in this function after the
+ // assignment (use 'raw_' instead).
raw_ = value;
- uword raw_value = reinterpret_cast<uword>(value);
- if ((raw_value & kSmiTagMask) == kSmiTag) {
+ if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) {
set_vtable(Smi::handle_vtable_);
return;
}
-#if defined(DEBUG)
- ValidateHeapObject(value);
-#endif // defined(DEBUG)
- set_vtable((value == null_) ?
- handle_vtable_ : value->ptr()->class_->ptr()->handle_vtable_);
+#ifdef DEBUG
+ Heap* isolate_heap = Isolate::Current()->heap();
+ Heap* vm_isolate_heap = Dart::vm_isolate()->heap();
+ ASSERT(isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())) ||
+ vm_isolate_heap->Contains(reinterpret_cast<uword>(raw_->ptr())));
+#endif
+ set_vtable((raw_ == null_) ?
+ handle_vtable_ : raw_->ptr()->class_->ptr()->handle_vtable_);
}
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698