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

Unified Diff: src/d8.cc

Issue 9866035: Add missing cast in d8 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index fdd7a94003f04987fa930531c6362019a58b162f..1e8b4c8a2011935672b7ac054b51a34ae932f8a4 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -427,6 +427,11 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
Persistent<Object> persistent_array = Persistent<Object>::New(array);
if (data == NULL && length != 0) {
+ // Make sure the total size fits into a (signed) int.
+ static const int kMaxSize = 0x7fffffff;
+ if (length > (kMaxSize - sizeof(size_t)) / element_size) {
+ return ThrowException(String::New("Array exceeds maximum size (2G)"));
+ }
// Prepend the size of the allocated chunk to the data itself.
int total_size = length * element_size + sizeof(size_t);
data = malloc(total_size);
@@ -460,7 +465,7 @@ void Shell::ExternalArrayWeakCallback(Persistent<Value> object, void* data) {
if (data != NULL && !prop_value->IsObject()) {
data = reinterpret_cast<size_t*>(data) - 1;
V8::AdjustAmountOfExternalAllocatedMemory(
- -(*reinterpret_cast<size_t*>(data)));
+ -static_cast<int>(*reinterpret_cast<size_t*>(data)));
free(data);
}
object.Dispose();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698