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

Unified Diff: runtime/vm/snapshot.cc

Issue 415513002: - Fix a lot of warnings generated by -Wshorten-64-to-32 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/snapshot.cc
===================================================================
--- runtime/vm/snapshot.cc (revision 38492)
+++ runtime/vm/snapshot.cc (working copy)
@@ -136,6 +136,11 @@
((1 << RawObject::kWatchedBit) | (1 << RawObject::kMarkBit)));
ASSERT((kObjectAlignmentMask & kObjectId) == kObjectId);
const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory);
+ // If the raw length is negative or greater than what the local machine can
+ // handle, then signal an error.
+ if ((snapshot->length_ < 0) || (snapshot->length_ > kIntptrMax)) {
+ return NULL;
+ }
return snapshot;
}
@@ -226,7 +231,8 @@
if ((value & kSmiTagMask) == kSmiTag) {
return NewInteger(value);
}
- return ReadObjectImpl(value);
+ ASSERT((value <= kIntptrMax) && (value >= kIntptrMin));
+ return ReadObjectImpl(static_cast<intptr_t>(value));
}
@@ -236,7 +242,6 @@
RawObject* SnapshotReader::ReadObjectImpl(intptr_t header_value) {
- ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin));
if (IsVMIsolateObject(header_value)) {
return ReadVMIsolateObject(header_value);
} else {
@@ -259,13 +264,14 @@
return NewInteger(header_value);
}
ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin));
- if (IsVMIsolateObject(header_value)) {
- return ReadVMIsolateObject(header_value);
- } else if (SerializedHeaderTag::decode(header_value) == kObjectId) {
- return ReadIndexedObject(SerializedHeaderData::decode(header_value));
+ intptr_t value = static_cast<intptr_t>(header_value);
+ if (IsVMIsolateObject(value)) {
+ return ReadVMIsolateObject(value);
+ } else if (SerializedHeaderTag::decode(value) == kObjectId) {
+ return ReadIndexedObject(SerializedHeaderData::decode(value));
}
- ASSERT(SerializedHeaderTag::decode(header_value) == kInlined);
- intptr_t object_id = SerializedHeaderData::decode(header_value);
+ ASSERT(SerializedHeaderTag::decode(value) == kInlined);
+ intptr_t object_id = SerializedHeaderData::decode(value);
if (object_id == kOmittedObjectId) {
object_id = NextAvailableObjectId();
}
@@ -705,8 +711,8 @@
RawObject* SnapshotReader::NewInteger(int64_t value) {
ASSERT((value & kSmiTagMask) == kSmiTag);
value = value >> kSmiTagShift;
- if ((value <= Smi::kMaxValue) && (value >= Smi::kMinValue)) {
- return Smi::New(value);
+ if (Smi::IsValid(value)) {
+ return Smi::New(static_cast<intptr_t>(value));
}
if (kind_ == Snapshot::kFull) {
return NewMint(value);
« no previous file with comments | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698